Johan Nilssons Lifestream

Python Scatter_Matrix Issue : 'matrix' object has no attribute '_get_numeric_data'

I have been trying to plot a lot of different time series against each others but I am unable to create a scatter_matrix.

Print(ptExcitationInside.as_matrix) returns :

[[<bound method NDFrame.as_matrix of                  Particle excitation inside(j)
date                                      
2017-03-07 08:00:00.779                7.0
2017-03-07 08:00:00.780                7.0
2017-03-07 08:00:00.781                7.0
...                                    ...
2017-03-06 14:34:32.041              168.0
2017-03-06 14:34:32.042              169.0

[23671264 rows x 1 columns]>]]

and Print(ptExcitationOutside.as_matrix) returns :

<bound method NDFrame.as_matrix of                          Particle excitation outside(j)
date                                      
2017-03-06 08:00:00.779               47.0
2017-03-06 08:00:00.780               47.0
2017-03-06 08:00:00.781               47.0
...                                    ...
2017-03-06 14:34:32.041              168.0
2017-03-06 14:34:32.042              169.0
[23671264 rows x 1 columns]>]]

I would like to use scatter_matrix to look at the correlation between the variables. (I have more than 2 time series like these, these are just examples)

I tried to create a big matrix observables = np.matrix[ptExcitationInside.as_matrix, ptExcitationOutside.as_matrix][ptExcitationInside.as_matrix, ptExcitationOutside.as_matrix] and pd.scatter_matrix(observables) but it returns :

AttributeError                            Traceback (most recent call last)
<ipython-input-232-218b3e0bf63a> in <module>()
 ----> 1 pd.scatter_matrix(observables, c='blue', alpha = 0.5, figsize = (10, 10), diagonal = 'kde');

/louis/anaconda3/lib/python3.6/site-packages/pandas/tools/plotting.py in scatter_matrix(frame, alpha, figsize, ax, grid, diagonal, marker, density_kwds, hist_kwds, range_padding, **kwds)
343     import matplotlib.pyplot as plt
344 
--> 345     df = frame._get_numeric_data()
346     n = df.columns.size
347     naxes = n * n

AttributeError: 'matrix' object has no attribute '_get_numeric_data'

so I tried to get only the value column but print((ptExcitationInside.as_matrix)[:,0]) returns :

    ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-227-b6ec50a21c53> in <module>()
  1 
----> 2 print((ptExcitationInside.as_matrix)[:,0])

TypeError: 'method' object is not subscriptable

Can someone help me, I am new to Python (first week on it), I am a C/Java developer and I don't know how to understand what variable types I am using.

EDIT :

<class 'pandas.core.frame.DataFrame'> DatetimeIndex: 23671264 entries, 2017-03-07 08:00:00.779000 to 2017-03-07 14:34:32.042000 
Freq: L Data columns (total 1 columns): Particle excitation inside float64 
dtypes: float64(1) memory usage: 361.2 MB 
<class 'pandas.core.frame.DataFrame'> 
DatetimeIndex: 23671264 entries, 2017-03-07 08:00:00.779000 to 2017-03-07 14:34:32.042000 
Freq: L Data columns (total 1 columns): Particle excitation outside 
float64 dtypes: float64(1) memory usage: 361.2 MB 

via Stack Overflow

blog comments powered by Disqus
Get the source for phplifestream at Github