Skip to content

Commit

Permalink
Add example same correlation in pandas.Series.corr documentation (#59591
Browse files Browse the repository at this point in the history
)
  • Loading branch information
fbourgey authored Aug 25, 2024
1 parent 631ab35 commit dca2635
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,13 @@ def corr(
>>> s2 = pd.Series([1, 2, 3], index=[2, 1, 0])
>>> s1.corr(s2)
-1.0
If the input is a constant array, the correlation is not defined in this case,
and ``np.nan`` is returned.
>>> s1 = pd.Series([0.45, 0.45])
>>> s1.corr(s1)
nan
""" # noqa: E501
this, other = self.align(other, join="inner")
if len(this) == 0:
Expand Down

0 comments on commit dca2635

Please sign in to comment.