Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pretty print pandas dataframe

# credit to Stack Overflow user in the source link

from tabulate import tabulate
import pandas as pd

df = pd.DataFrame({'col_two' : [0.0001, 1e-005 , 1e-006, 1e-007],
                   'column_3' : ['ABCD', 'ABCD', 'long string', 'ABCD']})
print(tabulate(df, headers='keys', tablefmt='psql'))

+----+-----------+-------------+
|    |   col_two | column_3    |
|----+-----------+-------------|
|  0 |    0.0001 | ABCD        |
|  1 |    1e-05  | ABCD        |
|  2 |    1e-06  | long string |
|  3 |    1e-07  | ABCD        |
+----+-----------+-------------+
Comment

pretty dataframe

df = pd.DataFrame({"A": [1, 2, 3], "B": [1, 2, 3]}, index=['a', 'a', 'b'])  
print(df.to_markdown()) 

|    |   A |   B |
|:---|----:|----:|
| a  |   1 |   1 |
| a  |   2 |   2 |
| b  |   3 |   3 |
Comment

PREVIOUS NEXT
Code Example
Python :: convert pdf to base64 python 
Python :: HOw to use passlock password manager python 
Python :: pandas change last row 
Python :: python loop through files in directory recursively 
Python :: python password generator 
Python :: import reverse_lazy 
Python :: python check if is pandas dataframe 
Python :: month from datetime pandas 
Python :: how to install python3 on ubuntu 
Python :: print all keys having same value 
Python :: check string similarity python 
Python :: how to plot kmeans graph 
Python :: extract float from string python 
Python :: discord py on ready 
Python :: pandas concat and reset index 
Python :: get max float value python 
Python :: python split path at level 
Python :: how to loop in python 
Python :: python print to file 
Python :: how to clear console in python 
Python :: tkinter image 
Python :: python convert current datetime to rfc 1123 format 
Python :: get role from name discord.py 
Python :: python average of two lists by row 
Python :: python shuffle list 
Python :: tkinter minsize 
Python :: django form password field 
Python :: python generate table 
Python :: read csv python pandas plot 
Python :: timestamp change python 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =