Skip to content

Commit 3f9686e

Browse files
thy09proost
authored andcommitted
BUG: .count() raises if use_inf_as_na is enabled (pandas-dev#29888)
1 parent 97c0fe9 commit 3f9686e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ Other
682682
- Bug in :meth:`DataFrame.append` that raised ``IndexError`` when appending with empty list (:issue:`28769`)
683683
- Fix :class:`AbstractHolidayCalendar` to return correct results for
684684
years after 2030 (now goes up to 2200) (:issue:`27790`)
685+
- Bug in :meth:`Series.count` raises if use_inf_as_na is enabled (:issue:`29478`)
685686

686687

687688
.. _whatsnew_1000.contributors:

pandas/core/dtypes/missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def _isna_old(obj):
176176
raise NotImplementedError("isna is not defined for MultiIndex")
177177
elif isinstance(obj, type):
178178
return False
179-
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass)):
179+
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass, ABCExtensionArray)):
180180
return _isna_ndarraylike_old(obj)
181181
elif isinstance(obj, ABCGeneric):
182182
return obj._constructor(obj._data.isna(func=_isna_old))

pandas/tests/series/test_analytics.py

+4
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ def test_count(self, datetime_series):
554554
ts.iloc[[0, 3, 5]] = np.nan
555555
tm.assert_series_equal(ts.count(level=1), right - 1)
556556

557+
# GH29478
558+
with pd.option_context("use_inf_as_na", True):
559+
assert pd.Series([pd.Timestamp("1990/1/1")]).count() == 1
560+
557561
def test_dot(self):
558562
a = Series(np.random.randn(4), index=["p", "q", "r", "s"])
559563
b = DataFrame(

0 commit comments

Comments
 (0)