DataFrame.corr(method ='pearson' , min_periods = 1 )
计算列的成对相关性,不包括NA/null
值。
参数: | method: pearson:标准相关系数 kendall:Kendall Tau相关系数 spearman:Spearman等级相关 callable:可输入两个1d ndarray来调用 并返回一个 min_periods : 观察每对列所需的最小数,以获得有效结果。 目前仅适用于pearson和spearman correlation |
返回: | y : |
例子
>>> histogram_intersection = lambda a, b: np.minimum(a, b
... ).sum().round(decimals=1)
>>> df = pd.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)],
... columns=['dogs', 'cats'])
>>> df.corr(method=histogram_intersection)
dogs cats
dogs 1.0 0.3
cats 0.3 1.0