I'm trying to count the coefficient. correlations for each pair of columns in the datarama.
data = pd.read_csv('data.txt', sep=" ", index_col="Id") print(data) 505 506 507 \ Id 0 NaN NaN NaN 1 37.2 107.0 69.0 2 NaN 130.0 72.0 for i in range(0, 3): for j in range(0, 3): if(j > i): a = data[data.columns[i:i+1]] b = data[data.columns[j:j+1]] r = a.corr(b) An error.
ValueError Traceback (most recent call last) <ipython-input-31-d85ca44785ee> in <module>() 5 b = data[data.columns[j:j+1]] 6 ----> 7 r = a.corr(b) ~\Anaconda3\envs\ML\lib\site-packages\pandas\core\frame.py in corr(self, method, min_periods) 5487 mat = numeric_df.values 5488 -> 5489 if method == 'pearson': 5490 correl = libalgos.nancorr(_ensure_float64(mat), minp=min_periods) 5491 elif method == 'spearman': ~\Anaconda3\envs\ML\lib\site-packages\pandas\core\generic.py in __nonzero__(self) 1119 raise ValueError("The truth value of a {0} is ambiguous. " 1120 "Use a.empty, a.bool(), a.item(), a.any() or a.all()." -> 1121 .format(self.__class__.__name__)) 1122 1123 __bool__ = __nonzero__ ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
a = data[data.columns[i:i+1]]orr = a.corr(b)- gil9reda = df[df.columns[0:1]] b = df[df.columns[1:2]] r = a.corr(b)- Andrey Stebenkov