In the draw_bar_plot
function I have the following code:
df_bar = pd.pivot_table(df, values='value', index=df.index.year, columns=df.index.month) month_list = pd.period_range(start="2022-01-01", end="2022-12-31", freq='M') month_list = [month.strftime("%B") for month in month_list] df_bar.columns = month_list
In Jupyter it neatly organizes data for the expected bar plot, which also meets the criteria of the assignment. Code as follows:
fig = plt.figure() ax = df_bar.plot(kind='bar', figsize=(6,5)) ax.set_xlabel('Years') ax.set_ylabel('Average Page Views') plt.legend(title='Months', fontsize=8)
However, on replit I get the following errors:
`ERROR: test_bar_plot_labels (test_module.BarPlotTestCase)
Traceback (most recent call last):
File “/home/runner/boilerplate-page-view-time-series-visualizer/test_module.py”, line 38, in setUp
self.ax = self.fig.axes[0]
IndexError: list index out of range
======================================================================
ERROR: test_bar_plot_legend_labels (test_module.BarPlotTestCase)
Traceback (most recent call last):
File “/home/runner/boilerplate-page-view-time-series-visualizer/test_module.py”, line 38, in setUp
self.ax = self.fig.axes[0]
IndexError: list index out of range
======================================================================
ERROR: test_bar_plot_number_of_bars (test_module.BarPlotTestCase)
Traceback (most recent call last):
File “/home/runner/boilerplate-page-view-time-series-visualizer/test_module.py”, line 38, in setUp
self.ax = self.fig.axes[0]
IndexError: list index out of range`
All pertain to the line 38, which is:
df_bar.columns = month_list
Please, kindly help me understand this difference between Jupyter and replit.