Data Analysis with Python Projects - Page View ... 'AxesSubplot' object is not subscriptable

Hi,

may I ask you for a help/hint? I obtain the following Error:TypeError: ‘AxesSubplot’ object is not subscriptable.
I suppose that the problem is in draw_bar_plot(). Especially in seaborn.barplot().
I tried many things, but nothing worked so far.

Here is the code:

code
Maybe pip install pandas,seaborn is necessary in shell in repl.it
I thank everybody in advance.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0.

Challenge: Page View Time Series Visualizer

Link to the challenge:

Take a look at documentation of barplot method in seaborn, it doesn’t return fig object.

Yes, but seaborn.barplot() returns ** ax : matplotlib Axes ** → Returns the Axes object with the plot drawn onto it.
I my case, test_module.py fails on TypeError: ‘AxesSubplot’ object is not subscriptable.
It fails on self.ax = self.fig.axes[0]. Probably,
barplot returns object fig.axes, but test_module.py needs self.ax = self.fig.axes[0]. It works when I rewrite self.ax = self.fig.axes[0] to self.ax = self.fig.axes intest_module.py, but this is not right, I suppose.

Don’t take me wrong, but I’m trying to understand this situation and find the solution. But it seems, that I have to use pandas.DataFrame.plot.hist as others, as test_module.py has the line self.ax = self.fig.axes[0]; rewrite test_module.py is prohibitted. And seaborn.barplot() has not subscriptable fig.axes. Or is there any solution?

Tests are expecting the figure object to be returned by draw_bar_plot, not ax.

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