-
-
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
Issues Creating Period with DateOffset as freq #4878
Comments
The exception actually looks like:
The more informative stack trace in the OP comes from making the following change: cancan101@6789ef8#L1R95 |
Some more examples of inconsistencies:
yields:
whereas:
works correctly. I have tracked part of this issue down: |
So this could be a simple fix, but I want to get some feedback: I plan to add this test: def test_period_range_alias(self):
self.assertTrue(
pd.date_range('1/1/2012', periods=4, freq=pd.offsets.MonthEnd()).to_period().identical(
pd.period_range('1/1/2012', periods=4, freq=pd.offsets.MonthEnd())))
#GH 4878
self.assertTrue(
pd.date_range('1/1/2012', periods=4, freq=pd.offsets.BusinessMonthEnd()).to_period().identical(
pd.period_range('1/1/2012', periods=4, freq=pd.offsets.BusinessMonthEnd()))) Currently the first line passes, but the second fails. To summarize the problem: Pandas uses def get_period_alias(offset_str):
""" alias to closest period strings BQ->Q etc"""
return _offset_to_period_map.get(offset_str, None) for which there is in fact a mapping One idea would be for Thoughts? |
@cancan101 weren't you thinking of reworking the backend for all of this? Would it make more sense to address this after you've made the changes there? I don't think there's any reason why we would not want your example to run without an error. |
@cancan101 Now it has a new error - hurray:
I guess I messed something up here. |
@jtratner That issue (at least the poor exception raised) is fixed on my retail branch. |
great - is that ready to go or soon to be ready? (not sure if you rebased it) |
See On Mon, Oct 14, 2013 at 11:04 PM, Jeff Tratner [email protected]:
|
This is with your PR; is this right?
|
Yes. Why? |
should the first not be freq 'BM'? |
I believe this is the "issue" I address here: https://github.com/pydata/pandas/pull/5148/files#diff-18135e4852fd97f51aabf9d5be9f528dR414 LMK if that does not make sense. |
ok...so why are they not different? |
Since this is a PeriodIndex, a monthly period is the same regardless of whether or not the period is defined by the start of month or end of month. |
ok, but say then you want to union it with another index which is not a business freq, why would that not be a problem? |
I actually misread your email. I thought you were saying begin vs end (not business vs regular month). As for BuisnessDay, there never was a Period for Business month. This PR should not change that. |
hmm...ok....so then a Period Business freq is essentially converted to a non-business freq then? maybe put up a warning for that? (or even raise), doubt their are tests for that |
this now raises a less cryptic It appears that the discussion here maybe now superseded by the discussion in #13871 so closing this one to help keep discussion in one place. |
Something seems wrong here:
correctly prints:
but:
leads to:
Strangely, the following both work:
The text was updated successfully, but these errors were encountered: