Skip to content

Instantly share code, notes, and snippets.

@mcai4gl2
Created April 30, 2017 21:00
Show Gist options
  • Save mcai4gl2/f90e15acdf2239f5659cd953f0f72d25 to your computer and use it in GitHub Desktop.
Save mcai4gl2/f90e15acdf2239f5659cd953f0f72d25 to your computer and use it in GitHub Desktop.
Print DataFrame as markdown table
import pandas as pd
from StringIO import StringIO
input_data = StringIO("""col1,col2,col3
1,2,3
4,5,6
7,8,9
""")
df = pd.read_csv(input_data, sep=",")
import tabulate
print tabulate.tabulate(df, df.columns, tablefmt="pipe", showindex=False)
@mcai4gl2
Copy link
Author

Output is:

col1 col2 col3
1 2 3
4 5 6
7 8 9

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