pretty print pandas dataframe

Solutions on MaxInterview for pretty print pandas dataframe by the best coders in the world

showing results for - "pretty print pandas dataframe"
Violeta
01 Sep 2016
1# credit to Stack Overflow user in the source link
2
3from tabulate import tabulate
4import pandas as pd
5
6df = pd.DataFrame({'col_two' : [0.0001, 1e-005 , 1e-006, 1e-007],
7                   'column_3' : ['ABCD', 'ABCD', 'long string', 'ABCD']})
8print(tabulate(df, headers='keys', tablefmt='psql'))
9
10+----+-----------+-------------+
11|    |   col_two | column_3    |
12|----+-----------+-------------|
13|  0 |    0.0001 | ABCD        |
14|  1 |    1e-05  | ABCD        |
15|  2 |    1e-06  | long string |
16|  3 |    1e-07  | ABCD        |
17+----+-----------+-------------+