Skip to content
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: df.resample('MS', closed='right') incorrectly places bins #55278

Conversation

MarcoGorelli
Copy link
Member

Comment on lines -192 to -193
"BQS": "Q",
"QS": "Q",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it odd that these "*start" offsets are here to begin with, as they don't have an associated Period:

In [22]: MonthEnd()._period_dtype_code
Out[22]: 3000

In [23]: MonthBegin()._period_dtype_code
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[23], line 1
----> 1 MonthBegin()._period_dtype_code

AttributeError: 'pandas._libs.tslibs.offsets.MonthBegin' object has no attribute '_period_dtype_code'

So, trying this - let's see what fails

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, this stuff is explicitly tested for...

@pytest.mark.parametrize("off", ["BQ", "QS", "BQS"])
def test_to_period_quarterlyish(self, off):
rng = date_range("01-Jan-2012", periods=8, freq=off)
prng = rng.to_period()
assert prng.freq == "Q-DEC"
@pytest.mark.parametrize("off", ["BA", "AS", "BAS"])
def test_to_period_annualish(self, off):
rng = date_range("01-Jan-2012", periods=8, freq=off)
prng = rng.to_period()
assert prng.freq == "A-DEC"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: df.resample('MS', closed='right') incorrectly places bins
1 participant