Boxplot error for Page View Time Series Analyzer

I’m working on the Data Analysis with Python project.

When I try to create a boxplot using seaborn,

# Prepare data for box plots (this block of code is given)
df_box = df.copy()
df_box['year'] = [d.year for d in]
df_box['month'] = [d.strftime('%b') for d in]

#Create Box Plot
fig, ax = plt.subplots(figsize=(10,10))
box_plot = sns.boxplot(data= df_box, x = "year", y = "value")

I would get a numpy attribute error:

Traceback (most recent call last):
File “”, line 66, in
box_plot = sns.boxplot(data= df_box, x = “year”, y = “value”)
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/”, line 2229, in boxplot
plotter = _BoxPlotter(x, y, hue, data, order, hue_order,
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/”, line 446, in init
self.establish_variables(x, y, hue, data, orient, order, hue_order)
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/”, line 158, in establish_variables
orient = self.infer_orient(x, y, orient)
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/”, line 359, in infer_orient
elif is_not_numeric(y):
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/”, line 339, in is_not_numeric
np.asarray(s, dtype=np.float)
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/numpy/”, line 305, in getattr
raise AttributeError(former_attrs[attr])
AttributeError: module ‘numpy’ has no attribute ‘float’.
np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
NumPy 1.20.0 Release Notes — NumPy v2.1.dev0 Manual

Is there a way to remedy this? I’m using Gitpod as my IDE.
Any leads would be appreciated.
Thank you so much.

I would update seaborn. This seems to have been fixed long ago.

Or downgrade numpy if you can’t update seaborn.

Not sure why the boilerplate is using seaborn 0.9.0 but it looks to be incompatible with numpy 1.20 and above.

thank you so much! yes, i checked the boilerplate for another project (medical data vizualizer) and it uses seaborn 0.13.2.

so for my code, I updated seaborn using

pip install seaborn --upgrade

in my gitpod workspace. And it solved the issue. Thanks so much!