Skip to content

Commit 7856c02

Browse files
authored
DOC: Added note for corr (#53972)
* 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
1 parent 6cb37b6 commit 7856c02

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/core/series.py

+10
Original file line numberDiff line numberDiff line change
@@ -2783,6 +2783,9 @@ def corr(
27832783
* `Kendall rank correlation coefficient <https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient>`_
27842784
* `Spearman's rank correlation coefficient <https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient>`_
27852785
2786+
Automatic data alignment: as with all pandas operations, automatic data alignment is performed for this method.
2787+
``corr()`` automatically considers values with matching indices.
2788+
27862789
Examples
27872790
--------
27882791
>>> def histogram_intersection(a, b):
@@ -2792,6 +2795,13 @@ def corr(
27922795
>>> s2 = pd.Series([.3, .6, .0, .1])
27932796
>>> s1.corr(s2, method=histogram_intersection)
27942797
0.3
2798+
2799+
Pandas auto-aligns the values with matching indices
2800+
2801+
>>> s1 = pd.Series([1, 2, 3], index=[0, 1, 2])
2802+
>>> s2 = pd.Series([1, 2, 3], index=[2, 1, 0])
2803+
>>> s1.corr(s2)
2804+
-1.0
27952805
""" # noqa: E501
27962806
this, other = self.align(other, join="inner", copy=False)
27972807
if len(this) == 0:

0 commit comments

Comments
 (0)