On this page
pandas.DataFrame.corr
DataFrame.corr(method='pearson', min_periods=1)
[source]-
Compute pairwise correlation of columns, excluding NA/null values.
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 .. versionadded:: 0.24.0
-
min_periods : int, optional
-
Minimum number of observations required per pair of columns to have a valid result. Currently only available for pearson and spearman correlation
Returns: -
y : DataFrame
See also
Examples
>>> 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
-
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.DataFrame.corr.html