133
Pandas DataFrame.corr()
The main task of the DataFrame.corr() method is to find the pairwise correlation of all the columns in the DataFrame. If any null value is present, it will automatically be excluded.
It also ignores non-numeric data type columns from the DataFrame.
Syntax
Parameters
method:
- pearson: standard correlation coefficient.
- kendall: Kendall Tau correlation coefficient.
- spearman: Spearman rank correlation.
- callable: callable with input two 1d ndarrays that returns a float value.
min_periods: It is an optional parameter that requires a minimum number of observations per pair of columns to return a valid result. Currently it is only available for the Pearson and Spearman correlation.
Returns
It returns a DataFrame correlation matrix.
Example
Output:
Pen Pencil Pen 1.0 1.1 Pencil1.1 1.0
Next TopicDataFrame.dropna()