Skip to content

Add example same correlation in pandas.Series.corr documentation #59591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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