Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nice output of pandas.DataFrame in org-mode
import pandas as pd
import numpy as np
from tabulate import tabulate

df = pd.DataFrame(np.random.random((4,3)), columns=['A','B','C'])
print("foo")
return(tabulate(df, headers="keys", tablefmt="orgtbl"))
ABC
00.7547990.4927220.144595
10.1984750.4177210.083459
20.6450110.4448570.278874
30.3148830.75210.789418

And :session version:

import pandas as pd
import numpy as np
from tabulate import tabulate

df = pd.DataFrame(np.random.random((4,3)), columns=['A','B','C'])
print("foo")
tabulate(df, headers="keys" ,headers="keys",tablefmt="orgtbl")
ABC
00.7325060.5085310.651031
10.01874860.4674980.391717
20.2318970.09885420.170519
30.7428870.105420.271825
@nakami

This comment has been minimized.

Copy link

@nakami nakami commented Jul 23, 2018

see
tabulate(df, headers="keys" ,headers="keys",tablefmt="orgtbl")

cannot use same keyword twice (headers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment