top_3_df_gb = sql_df[sql_df['BillingCountry'].isin(top_3_countries)].groupby([pd.Grouper(freq='M'), 'BillingCountry']).sum()
dfs = []
for country in top_3_countries:
c_df = top_3_df_gb.xs(country, level=1).cumsum()
c_df['Country'] = country
dfs.append(c_df)
full_c_df = pd.concat(dfs)
full_c_df.head()
full_c_df.reset_index(inplace=True)
sns.lineplot(data=full_c_df, x='InvoiceDate', y='Total', hue='Country')
No comments:
Post a Comment