-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Retain name in PeriodIndex resample #12771
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
Retain name in PeriodIndex resample #12771
Conversation
438b29c
to
8ecd0ef
Compare
@@ -652,9 +652,6 @@ def _convert_obj(self, obj): | |||
# Cannot have multiple of periods, convert to timestamp | |||
self.kind = 'timestamp' | |||
|
|||
if not len(obj): | |||
self.kind = 'timestamp' | |||
|
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'm not sure what the goal of this was. It made this test I added fail
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.
the kind
argument is quite tricky. We really should remove it, but that's a whole other project. The issue is that some of the routines are expecting DatetimeIndex
so we give it to them even though we are a PeriodIndexResampelr
. This all existed before the changed in 0.18.0, but was much trickier to deal with as it was function based. So should be possible to fix now.
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.
Am going to punt this to #12774, and loosen the associated test in this PR
pls don't change stuff just because py charm does |
I would remove it if I didn't think it made it better / cleaner. Happy to if you don't think it does... |
@@ -192,7 +192,7 @@ Bug Fixes | |||
|
|||
|
|||
- Bug in ``CategoricalIndex.get_loc`` returns different result from regular ``Index`` (:issue:`12531`) | |||
|
|||
- Bug in ``PeriodIndex.resample`` where name not propagated |
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.
add the issue number
cf1b05b
to
43ddeb2
Compare
run |
43ddeb2
to
3dbcba6
Compare
@jreback green |
result = s.resample('M').sum().index | ||
|
||
# would like to test vs the actual index, but due to GH12774, | ||
# currently only testing the length |
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.
no create the expected Series as it comes back
you can fix it later in the other issue
no I just fixed something on codecov |
3dbcba6
to
7b17a7e
Compare
index = PeriodIndex(start='2000', periods=0, freq='D', name='idx') | ||
s = Series(index=index) | ||
result = s.resample('M').sum() | ||
# after GH12774 is resolved, this should be a PeriodIndex |
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.
great. put a pointer to this PR in that issue (and maybe a checkbox), so we don't forget.
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.
done
looks good. ping on green. |
@jreback green, apart from the codecov anomaly |
thanks @MaximilianR I moved the tests to the proper location (and some other ones, not sure why there were there). now, if in
you will get some failures, could just be some test failures though (e.g. the expected need to change). |
git diff upstream/master | flake8 --diff