-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
BUG: Fix indexing on DatetimeBlock #27110
Conversation
pandas/core/internals/blocks.py
Outdated
@@ -1539,6 +1539,10 @@ def iget(self, col): | |||
col, loc = col | |||
if not com.is_null_slice(col) and col != 0: | |||
raise IndexError("{0} only contains one item".format(self)) | |||
if isinstance(col, slice): |
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.
could be elif
@@ -421,11 +421,12 @@ def test_agg_timezone_round_trip(): | |||
assert ts == grouped.nth(0)['B'].iloc[0] | |||
assert ts == grouped.head(1)['B'].iloc[0] | |||
assert ts == grouped.first()['B'].iloc[0] | |||
assert ts == grouped.apply(lambda x: x.iloc[0])[0] | |||
assert ts == grouped.apply(lambda x: x.iloc[0]).iloc[0, 0] |
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.
can you reference this issue and maybe put a comment here on whey this is like this
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.
or this is actually returning a single column DataFrame right? can you assert that
|
||
ts = df['B'].iloc[2] | ||
assert ts == grouped.last()['B'].iloc[0] | ||
assert ts == grouped.apply(lambda x: x.iloc[-1])[0] | ||
# FIXME: the next assertion is wrong; GH#26864 |
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.
same here
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.
also ok with moving these to a new test if easier
I'm pretty sure this problem also affects other EA blocks, will check and add tests if so |
@jreback any idea what’s up with the CI? |
|
method -> meth in the whatnew |
thanks @jbrockmendel |
git diff upstream/master -u -- "*.py" | flake8 --diff
Addresses one of the problems behind #26864, but probably doesn't address the statefullness problem there.