l = len(df.columns)
results = np.zeros((l,l))
for i, ac in enumerate(df):
for j, bc in enumerate(df):
results[j,i] = func(ac,bc)
results = DataFrame(results,index=df.columns,columns=df.columns)
Parameters
method : {'pearson', 'kendall', 'spearman'} or callable
* pearson : standard correlation coefficient
* kendall : Kendall Tau correlation coefficient
* spearman : Spearman rank correlation
* callable: callable with input two 1d ndarrays
and returning a float. Note that the returned matrix from corr
will have 1 along the diagonals and will be symmetric
regardless of the callable's behavior
.. versionadded:: 0.24.0
对于任何类型的perf(使用cythonizable函数)都需要在cython中执行此操作
查看的文档数据帧.corr()
也可以查看数据帧.corrwith()
警告:此方法计算对称相关矩阵,如CramrsV,但此方法不适用于TheilsU和其他非对称corr矩阵。在
相关问题 更多 >
编程相关推荐