jupyter notebook fancy print cross tab

Solutions on MaxInterview for jupyter notebook fancy print cross tab by the best coders in the world

showing results for - "jupyter notebook fancy print cross tab"
Sherine
17 Aug 2020
1#### credit to user in StackOverflow (see source link)
2#### works also with pd.crosstab
3
4from tabulate import tabulate
5import pandas as pd
6
7df = pd.DataFrame({'col_two' : [0.0001, 1e-005 , 1e-006, 1e-007],
8                   'column_3' : ['ABCD', 'ABCD', 'long string', 'ABCD']})
9print(tabulate(df, headers='keys', tablefmt='psql'))
10
11+----+-----------+-------------+
12|    |   col_two | column_3    |
13|----+-----------+-------------|
14|  0 |    0.0001 | ABCD        |
15|  1 |    1e-05  | ABCD        |
16|  2 |    1e-06  | long string |
17|  3 |    1e-07  | ABCD        |
18+----+-----------+-------------+