Skip to content

Commit 50ef24a

Browse files
committed
DOC: Clarify Series.eq behaviour with missing values
1 parent e72c8a1 commit 50ef24a

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

pandas/core/series.py

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
TYPE_CHECKING,
2121
Any,
2222
Literal,
23+
Self,
2324
cast,
2425
overload,
2526
)
@@ -40,6 +41,7 @@
4041
from pandas.errors import (
4142
ChainedAssignmentError,
4243
InvalidIndexError,
44+
Pandas4Warning,
4345
)
4446
from pandas.errors.cow import (
4547
_chained_assignment_method_msg,
@@ -191,7 +193,6 @@
191193
ReindexMethod,
192194
Renamer,
193195
Scalar,
194-
Self,
195196
SortKind,
196197
StorageOptions,
197198
Suffixes,
@@ -764,11 +765,13 @@ def values(self):
764765
array([1, 2, 3])
765766
766767
>>> pd.Series(list("aabc")).values
767-
array(['a', 'a', 'b', 'c'], dtype=object)
768+
<ArrowStringArrayNumpySemantics>
769+
['a', 'a', 'b', 'c']
770+
Length: 4, dtype: str
768771
769772
>>> pd.Series(list("aabc")).astype("category").values
770773
['a', 'a', 'b', 'c']
771-
Categories (3, object): ['a', 'b', 'c']
774+
Categories (3, str): ['a', 'b', 'c']
772775
773776
Timezone aware datetime data is converted to UTC:
774777
@@ -1471,7 +1474,7 @@ def to_string(
14711474
) -> None: ...
14721475

14731476
@deprecate_nonkeyword_arguments(
1474-
version="4.0", allowed_args=["self", "buf"], name="to_string"
1477+
Pandas4Warning, allowed_args=["self", "buf"], name="to_string"
14751478
)
14761479
def to_string(
14771480
self,
@@ -1629,7 +1632,7 @@ def to_markdown(
16291632
),
16301633
)
16311634
@deprecate_nonkeyword_arguments(
1632-
version="4.0", allowed_args=["self", "buf"], name="to_markdown"
1635+
Pandas4Warning, allowed_args=["self", "buf"], name="to_markdown"
16331636
)
16341637
def to_markdown(
16351638
self,
@@ -1970,7 +1973,7 @@ def groupby(
19701973
as_index: bool = True,
19711974
sort: bool = True,
19721975
group_keys: bool = True,
1973-
observed: bool = False,
1976+
observed: bool = True,
19741977
dropna: bool = True,
19751978
) -> SeriesGroupBy:
19761979
from pandas.core.groupby.generic import SeriesGroupBy
@@ -2144,12 +2147,12 @@ def unique(self) -> ArrayLike:
21442147
21452148
>>> pd.Series(pd.Categorical(list("baabc"))).unique()
21462149
['b', 'a', 'c']
2147-
Categories (3, object): ['a', 'b', 'c']
2150+
Categories (3, str): ['a', 'b', 'c']
21482151
>>> pd.Series(
21492152
... pd.Categorical(list("baabc"), categories=list("abc"), ordered=True)
21502153
... ).unique()
21512154
['b', 'a', 'c']
2152-
Categories (3, object): ['a' < 'b' < 'c']
2155+
Categories (3, str): ['a' < 'b' < 'c']
21532156
"""
21542157
return super().unique()
21552158

@@ -3109,7 +3112,8 @@ def combine(
31093112
Function that takes two scalars as inputs and returns an element.
31103113
fill_value : scalar, optional
31113114
The value to assume when an index is missing from
3112-
one Series or the other. The default specifies to use the
3115+
one Series or the other. Scalars are any value that is not a numpy.ndarray,
3116+
list, tuple or Series. The default specifies to use the
31133117
appropriate NaN value for the underlying dtype of the Series.
31143118
31153119
Returns
@@ -6070,6 +6074,11 @@ def eq(
60706074
Equivalent to ``series == other``, but with support to substitute a fill_value
60716075
for missing data in either one of the inputs.
60726076
6077+
By default, comparisons with missing values (e.g. ``np.nan``, ``pd.NA``) will
6078+
return ``False`` for those positions, even when comparing missing values to
6079+
themselves. If ``fill_value`` is specified, missing values are replaced before
6080+
comparison.
6081+
60736082
Parameters
60746083
----------
60756084
other : Series or scalar value
@@ -6683,7 +6692,7 @@ def any( # type: ignore[override]
66836692
filter_type="bool",
66846693
)
66856694

6686-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="all")
6695+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="all")
66876696
@Appender(make_doc("all", ndim=1))
66886697
def all(
66896698
self,
@@ -6703,7 +6712,7 @@ def all(
67036712
filter_type="bool",
67046713
)
67056714

6706-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="min")
6715+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="min")
67076716
def min(
67086717
self,
67096718
axis: Axis | None = 0,
@@ -6774,7 +6783,7 @@ def min(
67746783
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
67756784
)
67766785

6777-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="max")
6786+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="max")
67786787
def max(
67796788
self,
67806789
axis: Axis | None = 0,
@@ -6845,7 +6854,7 @@ def max(
68456854
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
68466855
)
68476856

6848-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="sum")
6857+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="sum")
68496858
def sum(
68506859
self,
68516860
axis: Axis | None = None,
@@ -6946,7 +6955,7 @@ def sum(
69466955
**kwargs,
69476956
)
69486957

6949-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="prod")
6958+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="prod")
69506959
@doc(make_doc("prod", ndim=1))
69516960
def prod(
69526961
self,
@@ -6965,7 +6974,7 @@ def prod(
69656974
**kwargs,
69666975
)
69676976

6968-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="mean")
6977+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="mean")
69696978
def mean(
69706979
self,
69716980
axis: Axis | None = 0,
@@ -7019,7 +7028,9 @@ def mean(
70197028
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
70207029
)
70217030

7022-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="median")
7031+
@deprecate_nonkeyword_arguments(
7032+
Pandas4Warning, allowed_args=["self"], name="median"
7033+
)
70237034
def median(
70247035
self,
70257036
axis: Axis | None = 0,
@@ -7100,7 +7111,7 @@ def median(
71007111
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
71017112
)
71027113

7103-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="sem")
7114+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="sem")
71047115
@doc(make_doc("sem", ndim=1))
71057116
def sem(
71067117
self,
@@ -7119,7 +7130,7 @@ def sem(
71197130
**kwargs,
71207131
)
71217132

7122-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="var")
7133+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="var")
71237134
def var(
71247135
self,
71257136
axis: Axis | None = None,
@@ -7206,7 +7217,7 @@ def var(
72067217
**kwargs,
72077218
)
72087219

7209-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="std")
7220+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="std")
72107221
@doc(make_doc("std", ndim=1))
72117222
def std(
72127223
self,
@@ -7225,7 +7236,7 @@ def std(
72257236
**kwargs,
72267237
)
72277238

7228-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="skew")
7239+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="skew")
72297240
@doc(make_doc("skew", ndim=1))
72307241
def skew(
72317242
self,
@@ -7238,7 +7249,7 @@ def skew(
72387249
self, axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
72397250
)
72407251

7241-
@deprecate_nonkeyword_arguments(version="4.0", allowed_args=["self"], name="kurt")
7252+
@deprecate_nonkeyword_arguments(Pandas4Warning, allowed_args=["self"], name="kurt")
72427253
def kurt(
72437254
self,
72447255
axis: Axis | None = 0,

0 commit comments

Comments
 (0)