Skip to content

Commit 19013fb

Browse files
committed
Move the method size to ExtensionArray.
Signed-off-by: HE, Tao <[email protected]>
1 parent 3f28f1e commit 19013fb

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

doc/source/whatsnew/v0.24.2.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ Fixed Regressions
3131
- Fixed regression in ``IntervalDtype`` construction where passing an incorrect string with 'Interval' as a prefix could result in a ``RecursionError``. (:issue:`25338`)
3232
- Fixed regression in :class:`Categorical`, where constructing it from a categorical ``Series`` and an explicit ``categories=`` that differed from that in the ``Series`` created an invalid object which could trigger segfaults. (:issue:`25318`)
3333
- Fixed pip installing from source into an environment without NumPy (:issue:`25193`)
34-
- Fixed regression in :meth:`Series.resample` when underlying array is :class:`IntegerArray`. (:issue:`25580`)
3534

3635
.. _whatsnew_0242.enhancements:
3736

3837
Enhancements
3938
^^^^^^^^^^^^
4039

41-
-
42-
-
40+
- Add :meth:`ExtensionArray.size` to return the number of elements in :class:`ExtensionArray` (:issue:`25580`)
4341

4442
.. _whatsnew_0242.bug_fixes:
4543

pandas/core/arrays/base.py

+13
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ExtensionArray(object):
4646
* __len__
4747
* dtype
4848
* nbytes
49+
* size
4950
* isna
5051
* take
5152
* copy
@@ -318,6 +319,18 @@ def nbytes(self):
318319
# on the number of bytes needed.
319320
raise AbstractMethodError(self)
320321

322+
@property
323+
def size(self):
324+
# type: () -> int
325+
"""
326+
The number of elements in this array.
327+
328+
Returns
329+
-------
330+
size : int
331+
"""
332+
return len(self)
333+
321334
# ------------------------------------------------------------------------
322335
# Additional Methods
323336
# ------------------------------------------------------------------------

pandas/core/arrays/integer.py

-4
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,6 @@ def __setitem__(self, key, value):
400400
def __len__(self):
401401
return len(self._data)
402402

403-
@property
404-
def size(self):
405-
return self._data.size
406-
407403
@property
408404
def nbytes(self):
409405
return self._data.nbytes + self._mask.nbytes

0 commit comments

Comments
 (0)