Skip to content

DEPR: Period[B] #53511

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

Merged
merged 12 commits into from
Jul 24, 2023
Merged

DEPR: Period[B] #53511

merged 12 commits into from
Jul 24, 2023

Conversation

jbrockmendel
Copy link
Member

There's a place in the plotting code where we apparently cast to Period, not sure why that would be necessary. Need to find an alternative before the deprecation is enforced.

@mroeschke mroeschke added Frequency DateOffsets Period Period data type Deprecate Functionality to remove in pandas labels Jun 5, 2023
@@ -217,6 +217,7 @@ def test_line_plot_period_mlt_frame(self, frqncy):
freq = df.index.asfreq(df.index.freq.rule_code).freq
_check_plot_works(df.plot, freq)

@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
Copy link
Member

Choose a reason for hiding this comment

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

do we need to find a workaround in plotting before doing this?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. suppressing the warning on this test is OK, but i think we need a better solution than suppressing here https://github.com/pandas-dev/pandas/pull/53511/files#diff-9e7653bee8c4fb4e42459af383020b7d754df6c55e79680d20e81d588d51f029R283

@mroeschke
Copy link
Member

+1 on deprecating. What about the other Business offsets?

@jbrockmendel
Copy link
Member Author

What about the other Business offsets?

The other business offsets aren't used for Period. (Confusion about that is common, which is part of why i want to decouple offsets from Period entirely)

return pd.period_range(start=dt, periods=k, freq="B", name=name, **kwargs)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
pi = pd.period_range(start=dt, periods=k, freq="B", name=name, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use another freq like "D"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing that breaks a handful of tests. I could go either way on changing it now vs after enforcement.

Copy link
Member

Choose a reason for hiding this comment

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

Would slightly prefer changing now to hopefully prevent potentially having to change more tests in the future

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, updated

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

generally looks good, just got a couple of questions on some tests

rng = period_range(start, end, freq=freq)
with warnings.catch_warnings():
# suppress Period[B] deprecation warning
warnings.simplefilter("ignore")
Copy link
Member

Choose a reason for hiding this comment

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

could we be more precise with the simplefilter please? I think this may set a bad example for new contributors wanting to silence warnings and looking for existing patterns of how to do it

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, will update

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

no objections

@mroeschke mroeschke added this to the 2.1 milestone Jul 24, 2023
@mroeschke mroeschke merged commit 4c67076 into pandas-dev:main Jul 24, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Frequency DateOffsets Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: Period[B]
3 participants