santosjorge / cufflinks

Productivity Tools for Plotly + Pandas
MIT License
3.02k stars 675 forks source link

Spread Chart Pandas Attribute Error #284

Open Hankins44 opened 1 year ago

Hankins44 commented 1 year ago

Versions

Python: 3.10.5

Pandas: 2.0.2

Plotly: 5.14.1

Cufflinks: 0.17.3

Issue

When running the following:

``` python df[['A','B']].iplot(kind='spread') ```

I get the following error:

``` python File ~\datasci\lib\site-packages\cufflinks\plotlytools.py:849, in _iplot..(x) 847 if kind=='spread': 848 trace=self.apply(lambda x:x[0]-x[1],axis=1) --> 849 positive=trace.apply(lambda x:x if x>=0 else pd.np.nan) 850 negative=trace.apply(lambda x:x if x<0 else pd.np.nan) 851 trace=pd.DataFrame({'positive':positive,'negative':negative}) AttributeError: module 'pandas' has no attribute 'np' ``` Pandas deprecated pandas.np in 1.0.0 and removed in 2.0.0
chw131 commented 1 year ago

I just downloaded the plotlytools.py from the Cufflinks GitHub site: https://github.com/santosjorge/cufflinks/tree/master/cufflinks Copy it into my pkg directory. This file was already updated for Pandas 2.0.x.

If you do not know where your cufflinks is installed, use pip install -U cufflinks to find out.

DimiM99 commented 9 months ago
File ~\datasci\lib\site-packages\cufflinks\plotlytools.py:849, in _iplot.<locals>.<lambda>(x)
    847 if kind=='spread':
    848   trace=self.apply(lambda x:x[0]-x[1],axis=1)
--> 849   positive=trace.apply(lambda x:x if x>=0 else pd.np.nan)
    850   negative=trace.apply(lambda x:x if x<0 else pd.np.nan)
    851   trace=pd.DataFrame({'positive':positive,'negative':negative})

AttributeError: module 'pandas' has no attribute 'np'

faced the same thing today, took a look at the code and thought "ta hell?".

this is actually fixed as of today, but the fix hasn't been pushed to pipy so the version u get get from pip install is broken.

I would suggest using pip install cufflinks1

DiMNDev commented 7 months ago

Took me a while to find this! Very helpful thank you!