Skip to content

Instantly share code, notes, and snippets.

@max-torch
Created May 21, 2021 11:10
Show Gist options
  • Save max-torch/1796b87214dba04c807146dcff48740a to your computer and use it in GitHub Desktop.
Save max-torch/1796b87214dba04c807146dcff48740a to your computer and use it in GitHub Desktop.
bssoupblog6
resampled_df_m = df_no_refund.resample('M', on='Date').sum().reset_index()
treemap2_df = resampled_df_m.copy()
treemap2_df['treeroot'] = 'Monthly Expense'
treemap2_df['Month'] = treemap2_df.Date.dt.month_name()
fig = px.treemap(
treemap2_df,
path=['treeroot', 'Month'],
values = 'Total',
title = 'Distribution of Steam Spending by Month',
)
fig.update_traces(hovertemplate = 'Month: %{label}<br>Expense: %{value:,.2f}<br>Percent of Total: %{percentRoot:.2%}')
fig.update_traces(
marker_showscale=False,
texttemplate='Month: %{label}<br>Expense: %{value:,.2f}<br>Percent of Total: %{percentRoot:.2%}'
)
fig.update_layout(hoverlabel=dict(bgcolor="white"))
fig.show()
fig.write_image("images/fig2.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment