Skip to content

BUG: Redefine IndexOpsMixin.size, fix #25580. #25584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Fixed Regressions
- Fixed regression in ``IntervalDtype`` construction where passing an incorrect string with 'Interval' as a prefix could result in a ``RecursionError``. (:issue:`25338`)
- 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`)
- Fixed pip installing from source into an environment without NumPy (:issue:`25193`)
- Fixed bug where :meth:`core.base.IndexOpsMixin.size` could not return correct result for :class:`api.extensions.ExtensionArray` (:issue:`25580`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to mention public API, so instead of core.base.IndexOpsMixin.size, I would use Series.size or Index.size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


.. _whatsnew_0242.enhancements:

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def nbytes(self):
"""
Return the number of bytes in the underlying data.
"""
return self._values.nbytes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the wrong property that is being changed? (nbytes, not size)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, will fix that soon.

return len(self._values)

@property
def strides(self):
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/resample/test_datetime_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ def test_resample_basic(series, closed, expected):
assert_series_equal(result, expected)


def test_resample_integerarray():
# GH 25580, resample on IntegerArray
ts = pd.Series(range(9),
index=pd.date_range('1/1/2000', periods=9, freq='T'),
dtype='Int64')
result = ts.resample('3T').sum()
expected = Series([3, 12, 21],
index=pd.date_range('1/1/2000', periods=3, freq='3T'),
dtype="Int64")
assert_series_equal(result, expected)


def test_resample_basic_grouper(series):
s = series
result = s.resample('5Min').last()
Expand Down