pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
2.03k stars 300 forks source link

module 'pandas' has no attribute 'scatter_matrix' #76

Closed Stuj79 closed 3 years ago

Stuj79 commented 5 years ago

I have just tried to rerun some code I wrote previously that worked at the time (March 2018) and now I receive an error.

When trying to use the ".plot_scatter_matrix()" method I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-69af71d84436> in <module>
----> 1 perf.plot_scatter_matrix()

~\.conda\envs\report_bt\lib\site-packages\ffn\core.py in plot_scatter_matrix(self, freq, title, figsize, **kwargs)
    915         plt.figure()
    916         ser = self._get_series(freq).to_returns().dropna()
--> 917         pd.scatter_matrix(ser, figsize=figsize, **kwargs)
    918         return plt.suptitle(title)
    919 

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

<Figure size 432x288 with 0 Axes>

The code that causes the issue is as follows:

import pandas as pd
import ffn

%matplotlib inline

import pandas_datareader.data as web

stocks = ['AAPL','AMZN','MSFT','NFLX']

data = web.DataReader(stocks,data_source='yahoo',start='01/01/2010')['Adj Close']

data.sort_index(ascending=True,inplace=True)

perf = data.calc_stats()

perf.plot_scatter_matrix()

Relevant packages used in environment:

numpy==1.16.3
pandas==0.24.2
pandas-datareader==0.7.0
ffn==0.3.4
matplotlib==3.1.0

Is this something that is known about, or something that is being caused by an incorrect module version etc.?

This link (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.plotting.scatter_matrix.html) seems to suggest it could be because the "scatter_matrix" method is under "pandas.plotting" rather than just "pandas". Could that be the cause?

y26805 commented 4 years ago

looks like pd.scatter_matrix() got deprecated and moved to pd.plotting.scatter_matrix in pandas 0.23.0 https://pandas.pydata.org/pandas-docs/version/0.23.0/whatsnew.html

requirements.txt rightly specified 0.22.0 (https://github.com/pmorissette/ffn/blob/ef86a714afbb6dab8fcbb897de4a4553f76e8073/requirements.txt#L4)

timkpaine commented 3 years ago

fixed in #143