Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'numpy' has no attribute 'float'. #3630

Closed
alcarnielo opened this issue Feb 5, 2024 · 6 comments
Closed

AttributeError: module 'numpy' has no attribute 'float'. #3630

alcarnielo opened this issue Feb 5, 2024 · 6 comments

Comments

@alcarnielo
Copy link

While performing a linear simple plot of the small DataFrame below:

        aoa        Cl        Cd   CL_corr   CD_corr
aoa00   0.0  0.001924  0.047507  0.001924  0.047507
aoa05   5.0  2.720128 -0.186944  2.726070  0.050842
aoa10  10.0  5.052481 -0.813212  5.116935  0.076496
aoa15  15.0  6.151317 -1.359491  6.293578  0.278911
aoa16  16.0  5.907987 -1.253804  6.024717  0.423229

when I run the following line:

sns.lineplot(data=df, x='CD_corr', y='CL_corr')

I faced the following error:

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:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

This error happens only on the lineplot method. I also tried the scatterplot (below) and it worked perffectly.

sns.scatterplot(data=df, x='CD_corr', y='CL_corr')

image

@thuiop
Copy link
Contributor

thuiop commented Feb 5, 2024

What version of seaborn are you using ? I expect this problem would go away by updating to the latest version. Also, it would be best to provide an easily reproducible example instead of a custom dataframe.

@alcarnielo
Copy link
Author

Bellow is the information of my seaborn obtained using conda list seaborn

# Name                    Version                   Build  Channel
seaborn                   0.10.1                     py_0    conda-forge
seaborn-base              0.12.1             pyhd8ed1ab_0 

The simple example replicating the issue that you request is below:

import pandas as pd
import seaborn as sns

a = {
     'A': [1,2,3,4,5,6],
     'B': [6,5,4,3,2,1]
     }

sns.lineplot(data=a, x='A', y='B')

@jhncls
Copy link

jhncls commented Feb 5, 2024

Did you try to upgrade seaborn? (Or downgrade numpy?) The packages seaborn is built on (matplotlib, numpy, pandas, scipy, ...) frequently introduce non-compatible changes, and the only way to cope, is to upgrade seaborn (or downgrade the conflicting library). Note that seaborn 0.10.1 is from April 2020.

@alcarnielo
Copy link
Author

I tried. with conda update seaborn just after the issue appeared to solve the issue, but it is still present there.

@thuiop
Copy link
Contributor

thuiop commented Feb 5, 2024

Your version of seaborn is severely outdated, the current version is 0.13. I am not sure why you have such an old version since Anaconda distributes 0.12 ; I recommend using conda-forge to install the latest version of seaborn.

@mwaskom
Copy link
Owner

mwaskom commented Feb 5, 2024

Looks like this was addressed in seaborn back in 2020: #2236

Your environment looks wonky as you have both seaborn and seaborn-base. I'd sort that out and then make sure that when you do import seaborn you're actually getting the updated version (print(seaborn.__version__))

@mwaskom mwaskom closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants