Data Analysis With Python Projects


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?!


full error traceback:

Traceback (most recent call last):
File “”, line 7, in
File “/workspace/boilerplate-page-view-time-series-visualizer/”, line 34, in draw_bar_plot
File “/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/seaborn/”, 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/”, line 1606, in init
self.establish_variables(x, y, hue, data, orient,
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

You can check the solution here:

" Solution

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


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

pip install seaborn --upgrade


or here:

“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

Thanks very much for the timely replay.

1 Like