Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mirbehroznoor/8cc75bd1797e943b10aa76a8a427a86f to your computer and use it in GitHub Desktop.
Save mirbehroznoor/8cc75bd1797e943b10aa76a8a427a86f to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment