首页 > 解决方案 > .corr() - Correlation ignores columns with numeric data

问题描述

I am trying to use df.corr() on a DataFrame and it is not returning correlation for all columns. Interestingly, it ignores the columns which are grey. Screen shot of DataFrame

I assign value to the 'grey' columns like that (with a for loop going through m):

Result_ARES.at[Result_ARES.NORAD==m,'popt0'] = popt[0]

I thought it might be a type issue. But type(popt[0]) is a numpy.float64.

Any ideas what I can do to rectify this?

Thank you,

标签: pythondataframecorrelation

解决方案


The 'data' in the column might have been a float but it was indexed as an object. The solution was to change all datatypes to float64 using this line of code:

Result_ARES = Result_ARES.astype('float64') 

推荐阅读