Skip to content

Commit 6375549

Browse files
sighingnowjorisvandenbossche
authored andcommitted
BUG: Redefine IndexOpsMixin.size, fix #25580. (#25584)
Signed-off-by: HE, Tao <[email protected]>
1 parent 43b949d commit 6375549

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

doc/source/whatsnew/v0.24.2.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ Bug Fixes
102102
- Bug in :meth:`Series.is_unique` where single occurrences of ``NaN`` were not considered unique (:issue:`25180`)
103103
- Bug in :func:`merge` when merging an empty ``DataFrame`` with an ``Int64`` column or a non-empty ``DataFrame`` with an ``Int64`` column that is all ``NaN`` (:issue:`25183`)
104104
- Bug in ``IntervalTree`` where a ``RecursionError`` occurs upon construction due to an overflow when adding endpoints, which also causes :class:`IntervalIndex` to crash during indexing operations (:issue:`25485`)
105-
-
105+
- Bug in :attr:`Series.size` raising for some extension-array-backed ``Series``, rather than returning the size (:issue:`25580`)
106+
- Bug in resampling raising for nullable integer-dtype columns (:issue:`25580`)
106107

107108
.. _whatsnew_0242.contributors:
108109

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ def size(self):
762762
"""
763763
Return the number of elements in the underlying data.
764764
"""
765-
return self._values.size
765+
return len(self._values)
766766

767767
@property
768768
def flags(self):

pandas/tests/resample/test_datetime_index.py

+12
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ def test_resample_basic(series, closed, expected):
101101
assert_series_equal(result, expected)
102102

103103

104+
def test_resample_integerarray():
105+
# GH 25580, resample on IntegerArray
106+
ts = pd.Series(range(9),
107+
index=pd.date_range('1/1/2000', periods=9, freq='T'),
108+
dtype='Int64')
109+
result = ts.resample('3T').sum()
110+
expected = Series([3, 12, 21],
111+
index=pd.date_range('1/1/2000', periods=3, freq='3T'),
112+
dtype="Int64")
113+
assert_series_equal(result, expected)
114+
115+
104116
def test_resample_basic_grouper(series):
105117
s = series
106118
result = s.resample('5Min').last()

pandas/tests/series/test_api.py

+7
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ def test_tab_complete_warning(self, ip):
493493
with provisionalcompleter('ignore'):
494494
list(ip.Completer.completions('s.', 1))
495495

496+
def test_integer_series_size(self):
497+
# GH 25580
498+
s = Series(range(9))
499+
assert s.size == 9
500+
s = Series(range(9), dtype="Int64")
501+
assert s.size == 9
502+
496503

497504
class TestCategoricalSeries(object):
498505

0 commit comments

Comments
 (0)