Data Analysis With Python Projects

Hi

When using the seaborn function barplot() i encountered this error!

from what i could find out it seems that there is a compatibility issue with numpy and seaborn library installed within the getpod’s vertualenv located in the Page View Time Series Visualizer project which is a part of the data analysis with python curriculum .

some debugging later i found that seborn uses the deprecated dtype=np.floatin two instances related to the foretold function, when manually changed to dtype=‘float’ everything runs fine!, so am i in the wrong here as in that’s the way it is purposefully setup or what?!

THX

full error traceback:

Traceback (most recent call last):
File “main.py”, line 7, in
time_series_visualizer.draw_bar_plot()
File “/workspace/boilerplate-page-view-time-series-visualizer/time_series_visualizer.py”, line 34, in draw_bar_plot
sns.barplot(
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/categorical.py”, line 3146, in barplot
plotter = _BarPlotter(x, y, hue, data, order, hue_order,
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/categorical.py”, line 1606, in init
self.establish_variables(x, y, hue, data, orient,
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/categorical.py”, line 158, in establish_variables
orient = self.infer_orient(x, y, orient)
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/categorical.py”, line 359, in infer_orient
elif is_not_numeric(y):
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/categorical.py”, line 339, in is_not_numeric
np.asarray(s, dtype=np.float)
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/numpy/init.py”, 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

You can check the solution here:
https://forum.freecodecamp.org/t/problem-in-data-analysis-with-python-projects-medical-data-visualizer/679791

" Solution

For staff: in template’s github repo, edit the ‘requirements.txt’ file to update the version of Seaborn.

seaborn==0.13.2

For learners:
While the issue is not solved, just upgrade your seaborn:

pip install seaborn --upgrade

"

or here:
https://forum.freecodecamp.org/t/data-analysis-with-python-projects-medical-data-visualizer/673292/3

“The tests might be written for the older verson and you can try downgrading it numpy on gitpod. You can use this command:”

pip install --force-reinstall numpy==1.20.3
2 Likes

Thanks very much for the timely replay.

1 Like