Skip to content

Commit

Permalink
DOC: Added note for corr (pandas-dev#53972)
Browse files Browse the repository at this point in the history
* Added note for corr

* Removed additional linebreak

* Added example and note for Series.corr

* Update frame.py

* Added operation in example

* Fixed indentation error for note

* Relocated notes
  • Loading branch information
rsm-23 authored and im-vinicius committed Jul 8, 2023
1 parent f5e7b89 commit 61715da
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2783,6 +2783,9 @@ def corr(
* `Kendall rank correlation coefficient <https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient>`_
* `Spearman's rank correlation coefficient <https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient>`_
Automatic data alignment: as with all pandas operations, automatic data alignment is performed for this method.
``corr()`` automatically considers values with matching indices.
Examples
--------
>>> def histogram_intersection(a, b):
Expand All @@ -2792,6 +2795,13 @@ def corr(
>>> s2 = pd.Series([.3, .6, .0, .1])
>>> s1.corr(s2, method=histogram_intersection)
0.3
Pandas auto-aligns the values with matching indices
>>> s1 = pd.Series([1, 2, 3], index=[0, 1, 2])
>>> s2 = pd.Series([1, 2, 3], index=[2, 1, 0])
>>> s1.corr(s2)
-1.0
""" # noqa: E501
this, other = self.align(other, join="inner", copy=False)
if len(this) == 0:
Expand Down

0 comments on commit 61715da

Please sign in to comment.