Skip to content

Commit dca2635

Browse files
authored
Add example same correlation in pandas.Series.corr documentation (#59591)
1 parent 631ab35 commit dca2635

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/core/series.py

+7
Original file line numberDiff line numberDiff line change
@@ -2619,6 +2619,13 @@ def corr(
26192619
>>> s2 = pd.Series([1, 2, 3], index=[2, 1, 0])
26202620
>>> s1.corr(s2)
26212621
-1.0
2622+
2623+
If the input is a constant array, the correlation is not defined in this case,
2624+
and ``np.nan`` is returned.
2625+
2626+
>>> s1 = pd.Series([0.45, 0.45])
2627+
>>> s1.corr(s1)
2628+
nan
26222629
""" # noqa: E501
26232630
this, other = self.align(other, join="inner")
26242631
if len(this) == 0:

0 commit comments

Comments
 (0)