Closed as not planned
Description
Bug summary
The boxplot function in the Datacamp Python iShell keeps giving python-errors regarding the set_ticks-function when calling the boxplot function with: jobs.boxplot(fontsize=6, vert=False), while the boxplot shows nevertheless, error-free.
Which makes it so that I cannot complete the exercise in the Datacamp curriculum.
Added file: ch5_employment.csv
Code for reproduction
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
jobs_file = 'https://assets.datacamp.com/production/course_5226/datasets/ch5_employment.csv'
# Read in jobs file
jobs = pd.read_csv(jobs_file)
# Convert datestamo column to a datetime object
jobs['datestamp'] = pd.to_datetime(jobs['datestamp'])
# Set the datestamp columns as the index of your DataFrame
jobs = jobs.set_index('datestamp')
# Generate a boxplot
jobs.boxplot(fontsize=6, vert=False)
plt.show()
# Generate numerical summaries
print(jobs.define())
Actual outcome
It keeps giving the error:
Traceback (most recent call last):
File "<stdin>", line 72, in exceptionCatcher
raise exception
File "<stdin>", line 3361, in run_ast_nodes
if (await self.run_code(code, result, async_=asy)):
File "<stdin>", line 3458, in run_code
self.showtraceback(running_compiled_code=True)
File "<stdin>", line 2066, in showtraceback
self._showtraceback(etype, value, stb)
File "<stdin>", line 72, in exceptionCatcher
raise exception
File "<stdin>", line 3441, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<stdin>", line 2, in <module>
jobs.boxplot(fontsize=6, vert=False)
File "<stdin>", line 511, in boxplot_frame
return plot_backend.boxplot_frame(
File "<stdin>", line 394, in boxplot_frame
ax = boxplot(
File "<stdin>", line 373, in boxplot
result = plot_group(columns, data.values.T, ax)
File "<stdin>", line 323, in plot_group
ax.set_yticklabels(keys, rotation=rot)
File "<stdin>", line 73, in wrapper
return get_method(self)(*args, **kwargs)
File "<stdin>", line 471, in wrapper
return func(*args, **kwargs)
File "<stdin>", line 1795, in _set_ticklabels
return self.set_ticklabels(labels, minor=minor, **kwargs)
File "<stdin>", line 1716, in set_ticklabels
raise ValueError(
ValueError: The number of FixedLocator locations (32), usually from a call to set_ticks, does not match the number of ticklabels (16).
Expected outcome
Although it does render a boxplot error-free, like so:
But this time without python-errors, please.
Additional information
Used environment:
Python: 3.9
Matplotlib: 3.4.3
Pandas: 1.3.4
Operating system
Windows 11
Matplotlib Version
Matplotlib: 3.4.3
Matplotlib Backend
module://matplotlib_custom_backend
Python version
3.9
Jupyter version
NA
Installation
pip
Metadata
Metadata
Assignees
Labels
No labels