Hi All! Thanks in advance for your help!
I’ve been pulling my hair out on this issue.
I have one test failing on the Page View Time Series Visualizer. (Error listed below) The test is expecting 49 bars but mine is reporting 57. If I remove the legend, then it report 45.
This appears to be the same exact issue in another post, but it doesn’t appear that a resolution was ever found. I’d post the link but I can only post one link in here and I figured my repl was more important.
Here is the link to my repl
Error Received
======================================================================
FAIL: 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 63, in test_bar_plot_number_of_bars
self.assertEqual(actual, expected, “Expected a different number of bars in bar chart.”)
AssertionError: 57 != 49 : Expected a different number of bars in bar chart.
Your code so far
def draw_bar_plot():
# Copy and modify data for monthly bar plot
df_bar = df.copy()
df_bar[‘year’] = df_bar.index.year
df_bar[‘month’] = df_bar.index.month_name()
df_bar = df_bar.groupby([‘year’, ‘month’]).mean().reset_index()
month_order = [‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’]
df_bar[‘month’] = pd.Categorical(df_bar[‘month’], categories=month_order, ordered=True)
df_bar = df_bar.sort_values(by=[‘year’, ‘month’])
# Draw bar plot
fig, ax = plt.subplots(figsize=(10,5))
sns.barplot(data=df_bar, x='year', y='value', hue='month', palette='Set1', hue_order=month_order, legend=True)
ax.legend(title='Months')
ax.set_xlabel('Years')
ax.set_ylabel('Average Page Views')
# Save image and return fig (don't change this part)
fig.savefig('bar_plot.png')
return fig
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Challenge Information:
Data Analysis with Python Projects - Page View Time Series Visualizer