-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
ENH: Cleanup backend for Offsets and Period #5148
Conversation
@@ -73,7 +73,7 @@ def get_freq(freq): | |||
return freq | |||
|
|||
|
|||
def get_freq_code(freqstr): | |||
def get_freq_code(freqstr, as_periodstr=False): |
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.
needs to default to do what it did before. [because I think this is actually a public method]
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.
@jtratner Am I missing something here? The change should by default not change behavior.
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.
okay.
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 updte docstring for parameters and returns
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.
@cancan101 please make sure to update docstring here
I know it seems weird, but feels like it would be much easier to just have DateOffset subclass str. |
@jtratner While there may be benefits to having DateOffset subclass str, I don't think we can rely on the rulecode being == corresponding DateOffset even in the case where DateOffset subclass str. |
no, it's not for eq, you'd override that anyways, it's more to not have to create 2 more properties (freq_obj, inferred_freq_offset) and a bunch of corresponding methods |
That might work as long as you made sure to return the str value was always the canonical string. For example you never got back 'Q' but rather instead got 'Q-MAR'. |
whatever you're going to have for I'm assuming you're going to change
|
Currently freq and freqstr are written: # alias to offset
@property
def freq(self):
return self.offset
@property
def freqstr(self):
return self.offset.freqstr I wrote this, but eventially this could be made more elegeant: @cache_readonly
def inferred_freq_offset(self):
try:
return get_offset(self.inferred_freq)
except ValueError:
return None |
@jtratner I am getting stuck now with the following: creating a period requires a period "code" or "base" (an integer). This integer code is used by The issue what I am trying to solve is taking data collected in 52-53 week fiscal years and up sampling to weeks. By design this should be a very clean upsampling (the quarters/years always end on the same day of the week). |
@cancan101 what specifically are you having trouble with in regards to |
I am still hacking around. Any hasattr will be done outside of any loop. On Wed, Oct 23, 2013 at 8:57 PM, Jeff Tratner [email protected]:
|
@cancan101 okay, well that was my quick response to your question. 😄 Ping me when you have something you'd like to ask about. To be clear: we've already merged the 52-53 week offset, so why wasn't this an issue in that PR when it is an issue now? |
There is no issue with the FY5253 et al. There are a number of pandas offsets which are not fully handled as periods. This DOES include the new 5253 offsets, but it also includes BQuarter (see #5091) and some others. I am trying to clean some of that up. |
@cancan101 okay - that's totally fine. |
Can you move the location of the 52-53 week classes in the offsets.py file? When you rebased they ended up inserted between |
Sure. I will tack on to this pr.
|
great |
Do you think that if: |
Nope, not going to be that way because of the special-case backwards-comptible reprs. Not a big deal. |
I actually think it can be. Or in many more cases it can be with a very small change. |
At least for:
|
@jtratner If you have time, could you take a look? I have a first pass at making it easier to add new periods / correctly support existing periods without having to get into cython code. |
@@ -1391,6 +1391,13 @@ def inferred_freq(self): | |||
except ValueError: | |||
return None | |||
|
|||
@cache_readonly |
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.
are you sure this can be cached like this? Is it possible that it will become inferred later on?
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 inferred_freq
property is also marked as cache_readonly
so I don't think so.
This is now passing tests. LMK what else needs to be done to get this merged. |
…efined Periods. Periods now hold reference to Offset rather than just freqstr (GH5148).
Was really hoping to see this get in 0.14, oh well. :( Does it look likely to make it for 0.14.1? I want to integrate it in dev efforts asap to clean up our attempts for more sanity from the Offsets and Periods. Thanks @cancan101, this is an epic one. |
well, this needs a rebase to even see it this works |
@cancan101 alex if you can rebase this on master I think can do this for 0.14.1 |
Hi all. Any progress? I guess a no go for 0.14.1 but still would be nice go get into master when possible after so we can get to know it. I was super excited about this one. 😃 |
I have this rebased and passing tests. Should I update release notes for 0.14.1? Or just wait for 0.15? |
0.15.0 |
closing. this would need a major rebase to be accepted. pls submit pr's for single inssues at a time. much easier to review / integrate. thanks. |
I think actually have done the rebase .
|
It's on a separate branch.
|
needs to target separate issues. linking them just makes this too complicated. |
Are there any parts of this PR that still make sense to try to get into master? |
These would need to be done as separata PRs because but so love to have these worked on (and the code as changed a bit since ths was originally posted) |
I did want to re-bump this PR / content, but I don't personally have time right now to tackle these. |
ok these issues r open and referenced |
This PR is a work in progress
Fixes #5306 - Removing unused imports
Fixes #5082 - Added
inferred_freq_offset
Fixes #5028 - fixed issues with
_offset_map
Fixes #4878 -
freq
parameter forPeriod
init supports full set of Offsets.Fixes #5418 - raise
DateParseError
rather than incorrectKeyError
for invalid frequencies