image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

calendar_df = pd.read_csv('../input/m5-forecasting-accuracy/calendar.csv', parse_dates=['date'], usecols=['date', 'd'])
calendar_stv = calendar_df[:1913]

sales_train_validation = pd.read_csv('../input/m5-forecasting-accuracy/sales_train_validation.csv', index_col='id')

aggregate_state_sum = sales_train_validation.groupby(by=['state_id'], axis=0).sum()
aggregate_state_sum.columns = calendar_stv['date']
agg_state_sum_trans = aggregate_state_sum.transpose()

plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = [20, 10]
plt.rcParams['lines.linewidth'] = 2
ax = agg_state_sum_trans['2015':].plot(title="Summeret salg per stat")
ax.set_ylabel('Solgte enheder')
plt.show()

aggregate_state_mean = sales_train_validation.groupby(by=['state_id'],axis=0).mean()
aggregate_state_mean.columns = calendar_stv['date']
agg_state_mean_trans = aggregate_state_mean.transpose()
plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = [20, 10]
plt.rcParams['lines.linewidth'] = 2
ax = agg_state_mean_trans['2015':].plot(title="Gennemsnitlig salg per stat")
ax.set_ylabel('Solgte enheder')
plt.show()

aggregate_state_category = sales_train_validation.groupby(by=['state_id', 'cat_id'], axis=0).sum()
aggregate_state_category.columns = calendar_stv['date']
agg_state_trans = aggregate_state_category.transpose()
plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = [20, 10]
plt.rcParams['lines.linewidth'] = 4

agg_state_trans['WI']['2015':].plot(title='WI')
plt.show()