Table
You can show your data in a better way in the Python notebook using Table
(Mercury Widget).
Example code:
import mercury as mr
import pandas as pd
# Example DataFrame
df = pd.DataFrame(
{
"name": ["Karol", "Szymon", "Piotr", "Ola"],
"second name": ["Falkowski", "Niewiński", "Płoński", "Płońska"],
"age": [20, 25, 38, 36],
}
)
mr.Table(data=df, width="200px", text_align="center")
Code explanation:
First step is installing needed packages:
- pandas to create an example DataFrame
- mercury to use
Mercury Widget
Secondly, choose or create the DataFrame. Lastly, write a function with data and other parameters included.
Parameters
data
(string) is a name of DataFrame which you want to show in table. This is necessary parameter!width
(value) sets width of columns in table. You enter the value usign px and don't have to type it every time (it sets automatically)text_align
(string) sets align of text in cells. It could be: right, left or center (default value is center).
Example
Jupyter Notebook code:
Result: