HHammond / PrettyPandas

A Pandas Styler class for making beautiful tables
http://prettypandas.readthedocs.org/
MIT License
415 stars 23 forks source link

Example should simply be copy/pastable #46

Closed scls19fr closed 6 years ago

scls19fr commented 6 years ago

Hello,

https://github.com/HHammond/PrettyPandas/blob/master/Readme.md provides an example but it should simply be copy/pastable

import pandas as pd
from pandas.compat import StringIO

dat = """A;B;C;D
10;58.0;0.07156;0.39343
2.51;64.0;1.21872;0.33958
5;56.0;1.38399;0.26289
2.51;47.0;0.45284;1.47185
5;46.0;1.19918;2.08354"""

df = pd.read_csv(StringIO(dat), sep=";")
df

from prettypandas import PrettyPandas

(PrettyPandas(df, precision=0)
 .as_percent(subset=['C', 'D'], precision=3)
 .as_money(subset='A')
 .average()
 .total()
)

Kind regards

HHammond commented 6 years ago

The examples are now copy and paste-able, except for the actual dataframe itself which I found too difficult to get the CSS right on the readthedocs page.