pandas df.corr() returns NaN despite data fed having populated data

前端 未结 1 1040
无人共我
无人共我 2020-12-19 18:50

My data looks like the following:

print data

                   A                B 
2014-04-04        163.24         191.77
2014-06-11           


        
相关标签:
1条回答
  • 2020-12-19 19:25

    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!]

    0 讨论(0)
提交回复
热议问题