-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fixed block placment from reindex(?) #24149
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
Conversation
Hello @TomAugspurger! Thanks for submitting the PR.
|
@@ -64,7 +64,8 @@ cdef class BlockPlacement: | |||
|
|||
return '%s(%r)' % (self.__class__.__name__, v) | |||
|
|||
__repr__ = __str__ | |||
def __repr__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is a cython bug, but I wasn't getting a nice repr. without this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually you would just do
__repr__ = __str__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, that's what I deleted. But on master I get this for the repr.
In [1]: import pandas as pd; import numpy as np; import pickle
In [2]: pd.Series([1,2])._data._block.mgr_locs
Out[2]: <pandas._libs.internals.BlockPlacement object at 0x111b65048>
In [10]: x.__repr__
Out[10]: <method-wrapper '__str__' of pandas._libs.internals.BlockPlacement object at 0x10ed26278>
In [11]: repr(x)
Out[11]: '<pandas._libs.internals.BlockPlacement object at 0x10ed26278>'
In [12]: x.__repr__()
Out[12]: 'BlockPlacement(slice(0, 2, 1))'
I assume it's some behavior difference between Cython and Python.
@@ -1887,7 +1887,7 @@ def take_nd(self, indexer, axis=0, new_mgr_locs=None, fill_tuple=None): | |||
allow_fill=True) | |||
|
|||
# if we are a 1-dim object, then always place at 0 | |||
if self.ndim == 1: | |||
if self.ndim == 1 and new_mgr_locs is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea if this is going to break things.
Oh and I notice that the comment is out of date now.
@@ -164,6 +164,15 @@ def test_combine_add(self, data_repeated): | |||
orig_data1._from_sequence([a + val for a in list(orig_data1)])) | |||
self.assert_series_equal(result, expected) | |||
|
|||
@pytest.mark.xfail(reason="GH-24147", strict=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a test for the original bug from the issue. Unfortunately, it doesn't run yet since Series.where
loses the extension dtype. #24147 is fixing that.
Codecov Report
@@ Coverage Diff @@
## master #24149 +/- ##
==========================================
- Coverage 92.2% 92.2% -0.01%
==========================================
Files 162 162
Lines 51700 51700
==========================================
- Hits 47670 47669 -1
- Misses 4030 4031 +1
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #24149 +/- ##
==========================================
- Coverage 92.2% 92.2% -0.01%
==========================================
Files 162 162
Lines 51700 51700
==========================================
- Hits 47670 47669 -1
- Misses 4030 4031 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comment, lgtm otherwise
@@ -64,7 +64,8 @@ cdef class BlockPlacement: | |||
|
|||
return '%s(%r)' % (self.__class__.__name__, v) | |||
|
|||
__repr__ = __str__ | |||
def __repr__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually you would just do
__repr__ = __str__
Going to merge this now, and merge https://github.com/pandas-dev/pandas/pull/24114/files on top of it, which will enable the rest of the tests. I'll fix the stale comment in |
Closes #24147