pandas.DataFrame.corrwith

pandas 3.1.1 · DataFrame · method

Calculate correlations with corresponding rows or columns of another object.

Call syntax

DataFrame.corrwith(
    other,
    axis=0,
    drop=False,
    method='pearson',
    numeric_only=False,
    min_periods=None,
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
other Required
Positional or keyword
DataFrame, Series

Supply the second object or value used in the operation.

axis Optional
Positional or keyword
Default 0
{0 or 'index', 1 or 'columns'}

Choose which axis the operation acts on. The accepted axis labels depend on the receiver.

drop Optional
Positional or keyword
Default False
bool

Choose whether removed labels or levels are kept as data where supported.

method Optional
Positional or keyword
Default 'pearson'
{'pearson', 'kendall', 'spearman'} or callable

Choose the algorithm used to calculate, align, or fill the result.

numeric_only Optional
Positional or keyword
Default False
bool

Restrict the calculation to columns pandas considers numeric where applicable.

min_periods Optional
Positional or keyword
Default None
int

Require this many valid observations in a window before pandas reports a value.

Returns

Series