Created
January 4, 2023 15:38
-
-
Save samchaaa/1f19bcb5520a30390f83007ccc6ffe95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
agg_flow | |
.reset_index() | |
.style | |
# after this we are not working a a dataframe but a "styler" object | |
.format({'cost': '${:,.2f}', 'datetime': '{:%Y/%m}/01', | |
'percent_quarterly flow': '{:.1%}', | |
'off_goal': '{:+.1%}', | |
**{col: '{:.1f}' for col in ['cfs', 'total_flow', 'quarterly_flow']}}, | |
na_rep='Missing') | |
.bar(subset='cfs', color='#cO7fef', vmax=agg flow.cfs.quantile(.95)) | |
.bar(subset='off_goal', color=['red', 'green'], align='mid') | |
.highlight_null(null_color='#fef78c') # wish this was highlight_na | |
.highlight_max(axis=0, color='green') | |
.background_gradient(axis=0, cmap='Reds', subset='cost', vmin=1_000, vmax=25_008) | |
.set_caption('Dirty Devil Summary’) | |
.set_properties(**{'background-color': '#999'}, subset='datetime') | |
.applymap(lambda val: f'color: "grey"; opacity: 80%; background-color: {"#4589ae" if val > 0 else "#cO7fef"}' , | |
subset='cfs') | |
# .set_table_ styles breaks stick headers if it is after | |
.set_table_styles([{'selector': 'td:hover', 'props': 'background-color: pink; font-size: 14pt;'}]) | |
.set_sticky(axis="columns") | |
.hide_index() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment