df['year'] = [x for x in df.index.year] df['month'] = [x for x in df.index.month] df['year_month'] = [str(x.year) + '_' + str(x.month) for x in df.index] df_plot = df[df['year'] >= 2017].reset_index().sort_values(by='Datetime').set_index('Datetime') plt.title(f'Boxplot Year Month Distribution'); plt.xticks(rotation=90) plt.xlabel('Year Month') plt.ylabel('MW') sns.boxplot(x='year_month', y='PJME_MW', data=df_plot) plt.ylabel('Consumption [MW]') plt.xlabel('Year Month')