Created
April 30, 2017 21:00
-
-
Save mcai4gl2/f90e15acdf2239f5659cd953f0f72d25 to your computer and use it in GitHub Desktop.
Print DataFrame as markdown table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output is: