Pandaspretty is a python package which provides you feature to convert your DataFrame in a good looking table, just in few steps. It aims to make everything simple.
- More customizable options
- New methods to create
- Custom styles
- Attractive tables
- Fast
- Automatically resizable cells
The source code is currently available on github
To install it using PIP use the following command
pip install Pandaspretty
Let's suppose you have a DataFrame named df having value
Name | Class | Roll_no | Section | |
---|---|---|---|---|
0 | Ayush kumar | 12 | 8 | A |
1 | Prince kumar | 12 | 23 | A |
2 | Khushi singh | 12 | 18 | B |
3 | Prathisha | 12 | 23 | B |
import Pandaspretty as pp
[...]
prettyfied = pp.pretty(df)
print(prettyfied)
+----------------+---------+-----------+-----------+
| Name | Class | Roll_no | Section |
+----------------+---------+-----------+-----------+
| Ayush kumar | 12 | 8 | A |
+----------------+---------+-----------+-----------+
| Prince kumar | 12 | 23 | A |
+----------------+---------+-----------+-----------+
| Khushi singh | 12 | 18 | B |
+----------------+---------+-----------+-----------+
| Prathisha | 12 | 23 | B |
+----------------+---------+-----------+-----------+
import Pandaspretty as pp
-
pretty(data = df, corner='%', separator=';', joins='=')
-
to_sql(data, index = True)
-
tabulate(data,index = True ,corner = '+', separator='|', joins='-')
-
data : Accepts a dataframe object.
-
index : Set index True/False to see the index of dataframe in table (default value is "True").
-
corner : Accepts character to be shown on corner points (default value is "+").
-
separator : Accepts character to be shown in place to the line separating two values (default value is "|").
-
joins : Accepts character to be shown in place to the line joining two rows (default value is "-").
[...]
prettyfied = pp.pretty(data = df, index = True ,corner='%', separator=';', joins='=')
print(prettyfied)
%=====%================%=========%===========%===========%
; ; Name ; Class ; Roll_no ; Section ;
%=====%================%=========%===========%===========%
; 0 ; Ayush kumar ; 12 ; 8 ; A ;
%=====%================%=========%===========%===========%
; 1 ; Prince kumar ; 12 ; 23 ; A ;
%=====%================%=========%===========%===========%
; 2 ; Khushi singh ; 12 ; 18 ; B ;
%=====%================%=========%===========%===========%
; 3 ; Prathisha ; 12 ; 23 ; B ;
%=====%================%=========%===========%===========%
[...]
prettyfied = pp.pretty(data = df, corner='#')
print(prettyfied)
#-----#----------------#---------#-----------#-----------#
| | Name | Class | Roll_no | Section |
#-----#----------------#---------#-----------#-----------#
| 0 | Ayush kumar | 12 | 8 | A |
#-----#----------------#---------#-----------#-----------#
| 1 | Prince kumar | 12 | 23 | A |
#-----#----------------#---------#-----------#-----------#
| 2 | Khushi singh | 12 | 18 | B |
#-----#----------------#---------#-----------#-----------#
| 3 | Prathisha | 12 | 23 | B |
#-----#----------------#---------#-----------#-----------#
[...]
prettyfied = pp.pretty(data = df, index = False, separator='!')
print(prettyfied)
+----------------+---------+-----------+-----------+
! Name ! Class ! Roll_no ! Section !
+----------------+---------+-----------+-----------+
! Ayush kumar ! 12 ! 8 ! A !
+----------------+---------+-----------+-----------+
! Prince kumar ! 12 ! 23 ! A !
+----------------+---------+-----------+-----------+
! Khushi singh ! 12 ! 18 ! B !
+----------------+---------+-----------+-----------+
! Prathisha ! 12 ! 23 ! B !
+----------------+---------+-----------+-----------+
[...]
prettyfied = pp.to_sql(data = df, index = False)
print(prettyfied)
+----------------+---------+-----------+-----------+
| Name | Class | Roll_no | Section |
+----------------+---------+-----------+-----------+
| Ayush kumar | 12 | 8 | A |
| Prince kumar | 12 | 23 | A |
| Khushi singh | 12 | 18 | B |
| Prathisha | 12 | 23 | B |
+----------------+---------+-----------+-----------+
[...]
prettyfied = pp.to_sql(data = df, index = True)
print(prettyfied)
+-----+----------------+---------+-----------+-----------+
| | Name | Class | Roll_no | Section |
+-----+----------------+---------+-----------+-----------+
| 0 | Ayush kumar | 12 | 8 | A |
| 1 | Prince kumar | 12 | 23 | A |
| 2 | Khushi singh | 12 | 18 | B |
| 3 | Prathisha | 12 | 23 | B |
+-----+----------------+---------+-----------+-----------+
[...]
prettyfied = pp.tabulate(data = df, separator=':')
print(prettyfied)
+-----+----------------+---------+-----------+-----------+
: : Name : Class : Roll_no : Section :
+-----+----------------+---------+-----------+-----------+
: 0 : Ayush kumar : 12 : 8 : A :
: 1 : Prince kumar : 12 : 23 : A :
: 2 : Khushi singh : 12 : 18 : B :
: 3 : Prathisha : 12 : 23 : B :
+-----+----------------+---------+-----------+-----------+
[...]
prettyfied = pp.tabulate(data = df, separator=':', index = False, joins = '—', corner='#')
print(prettyfied)
#————————————————#—————————#———————————#———————————#
: Name : Class : Roll_no : Section :
#————————————————#—————————#———————————#———————————#
: Ayush kumar : 12 : 8 : A :
: Prince kumar : 12 : 23 : A :
: Khushi singh : 12 : 18 : B :
: Prathisha : 12 : 23 : B :
#————————————————#—————————#———————————#———————————#
Social Handles : github | sololearn | instagram | stackoverflow