Page View Time Series Visualizer TEST Problem

So, the console keeps saying this:

FAIL: test_box_plot_number_of_boxes (test_module.BoxPlotTestCase)

Traceback (most recent call last):
File “/home/runner/boilerplate-page-view-time-series-visualizer/test_module.py”, line 120, in test_box_plot_number_of_boxes
self.assertEqual(actual, expected, “Expected 12 boxes in box plot 2”)
AssertionError: 0.0 != 12 : Expected 12 boxes in box plot 2


The thing is that the error is not real. If i run the test equation in my colab notebook it returns 12.

len(axes[1].lines)/6
12.0

Also keep in mind that, the checks for other attributes like the title in the ax1 and ax2 pass without problems.


My code:
def draw_box_plot():
# Prepare data for box plots (this part is done!)
df_new = df.set_index(“date”)
df_new.index = pd.to_datetime(df_new.index)
df_new[‘month’] = df_new.index.month
df_new[‘year’] = df_new.index.year
fig,(ax1,ax2) = plt.subplots(1,2,figsize=(40,10))
sns.boxplot(ax=ax1,data=df_new,x=“year”,y=“value”)
ax1.set_xlabel(“Year”)
ax1.set_ylabel(“Page Views”)
ax1.set_title(“Year-wise Box Plot (Trend)”)
sns.boxplot(ax=ax2,data=df_new,x=“month”,y=“value”, order=[“January”,“February”,“March”,“April”,“May”,“June”,“July”,“August”,“September”,“October”,“November”,“December”])
ax2.set_xlabel(“Month”)
ax2.set_ylabel(“Page Views”)
ax2.set_title(“Month-wise Box Plot (Seasonality)”)
ax2.set_xticklabels([“Jan”,“Feb”,“Mar”,“Apr”,“May”,“Jun”,“Jul”,“Aug”,“Sep”,“Oct”,“Nov”,“Dec”])

Save image and return fig (don’t change this part)

fig.savefig(‘box_plot.png’)
return fig


Hope u can help me… TY

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Challenge: Page View Time Series Visualizer

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.