Saturday, June 26, 2021

【PYTHON】Another way to collect and plot the same data

 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

End of Summer Sale ☀️😎

20% OFF Inside!🤯 ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏...