Skip to content

Instantly share code, notes, and snippets.

@aboucaud
Last active May 13, 2020 17:24
Show Gist options
  • Select an option

  • Save aboucaud/0546cdf6e8d9a359e81f7473a14b7b19 to your computer and use it in GitHub Desktop.

Select an option

Save aboucaud/0546cdf6e8d9a359e81f7473a14b7b19 to your computer and use it in GitHub Desktop.
[Pandas table styling] #python #visualisation
# https://pandas.pydata.org/pandas-docs/stable/reference/style.html
# https://towardsdatascience.com/style-pandas-dataframe-like-a-master-6b02bf6468b0
import pandas as pd
# Option examples
pd.set_option('precision', 4)
pd.set_option('max_rows', 10)
pd.set_option('max_columns', 7)
pd.set_option("display.max_colwidth", -1)
# Table styling
(df.head(10)
.style
.format({
"Dollars": "${:20,.0f}",
"Euros": "{:20,.0f}€",
"Title": lambda x: x.lower()})
.hide_index()
.background_gradient(subset=["Dollars"], cmap='Reds')
.bar(subset=["Euros"], color='lightgreen'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment