Skip to content Skip to sidebar Skip to footer

Pandas Df.corr() Returns NaN Despite Data Fed Having Populated Data

My data looks like the following: print data A B 2014-04-04 163.24 191.77 2014-06-11 165.43 182.25 2014-12-22

Solution 1:

Jason, Using the sample data it works fine for me.

data.corr()
    A   B
A   1.000000    -0.779864
B   -0.779864   1.000000

I noticed in your data.info() there is a 'None' tacked on to dtypes. When I load your sample data I get

data.info()
<class 'pandas.core.frame.DataFrame'>
Index: 30 entries, 2014-04-04 to 2014-12-29
Data columns (total 2 columns):
A     30 non-null float64
B     30 non-null float64
dtypes: float64(2)

I imagine what's causing that 'None' is causing your problem.

Hope this helps [wish I could leave as a comment but don't have the reputation yet!]


Post a Comment for "Pandas Df.corr() Returns NaN Despite Data Fed Having Populated Data"