-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: Period[B] #53446
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
Comments
Any chance you could include an example of what you'd like to deprecate, and what users should do instead please? |
For the PeriodIndex cases I'd advise users to use a DatetimeIndex with freq="B". For the a user would be out of luck. |
sounds fine, thanks! |
This now seems to be causing a lot of warnings when simply calling
Any chance this can be fixed? I (guess I) understand deprecating this use of the |
@jbrockmendel do you remember if there were any challenges with silencing this warnings for the plotting code? |
Also, what's curious is that running my script throws with
even though I added the following at the very start of my entry point: warnings.simplefilter("error")
warnings.filterwarnings("ignore", "Period with BDay freq is deprecated", FutureWarning)
warnings.filterwarnings(
"ignore", "PeriodDtype[B] is deprecated and will be removed", FutureWarning
) I.e. that second filter I added does override the very first |
IIIRC it was as normal filterwarnings without any complications. There's a note-to-self that we need a better solution before the deprecation is enforced. |
A very simple repro showing the warnings happening is as follows: import warnings
import pandas._testing as tm
warnings.simplefilter("error")
_ = tm.makeTimeDataFrame().plot() For me this throws even with the latest checkout of the repo. In fact, the first test in
Stepping through the plotting code it looks to me like that place where this note was put is not sufficient to capture all instances of the warning: it silences the warning that would happen on line 1363 of Given the warning should be suppressed for the most naive and simple use of plotting functionality, may I suggest the warning filter get moved way higher up the hierarchy, potentially all the way to the |
I'd be open to that, but first I'd like to try getting the warning suppression closer to the source of the problem. I can get the example you posted to run by catching warnings in PeriodConverter.convert_1d and PR would be welcome. |
@jbrockmendel I submitted a PR based on your suggestions: #55138. I still feel that a single filter at the level of, say, |
Before this change test_period_object_column fails with the message below: FAILED qgrid/tests/test_grid.py::test_period_object_column - OverflowError: Maximum recursion level reached After this change the test passes. See also pandas-dev/pandas#53446
Before this change test_period_object_column fails with the message below: FAILED qgrid/tests/test_grid.py::test_period_object_column - OverflowError: Maximum recursion level reached After this change the test passes. See also pandas-dev/pandas#53446
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
NA
Issue Description
TL;DR: can we deprecate BDay Period(|Dtype|Index|Array) and tell users to use a DatetimeIndex with freq="B" instead?
Context: lots of user confusion has resulted from a) using "freq" for PeriodX to mean something different than it does for DatetimeIndex (#51256, #38885, #47227) and b) using DateOffsets to define PeriodX (#5091, #13871, #38914, #38859).
The option I'm leaning toward to address this is to change/deprecate PeriodX.freq to "unit" (the attribute, the constructor keywords, and asfreq->as_unit). The sticking point I'm finding is in finding a replacement for the current usage
period + period.freq * N
. For everything except BDay, we could tell users to do something likeperiod + np.timedelta64(N, period.unit)
instead (actually justperiod + N
works, but I'd actually prefer to deprecate that).So I'm wondering if we really need to support Period[B]. Anyone have a strong opinion?
Expected Behavior
NA
Installed Versions
Replace this line with the output of pd.show_versions()
The text was updated successfully, but these errors were encountered: