-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
DEPR: DatetimeIndex/TimedeltaIndex constructor keywords #55499
Comments
sounds good, would favour moving towards to_datetime as being the way to parse into datetime |
Agreed, would be simpler if DTI/TDI just accepted correctly typed arrays |
See some related notes in #50894 and #50411 (comment), where it is also brought to let DatetimeIndex only accept ISO8601 strings, and the first issue also has some notes on differences in keywords between DatetimeIndex and to_datetime. There is the more general question about what to support as input (only correctly typed arrays, still strings but only ISO formatted, anything that works with the Series/Index constructor when specifying the dtype, ..), although I think that for most of the keywords that's actually not that relevant. I think
To me this feels like the one keyword that actually makes sense to keep in the DatetimeIndex constructor, since it is a DatetimeIndex specific attribute? (like you can also set
I also like the
I think |
I've looked into this and determined the following: In the DatetimeIndex constructor We could push ambiguous into the cython So i think we are safe:
|
Tried deprecating ambiguous, dayfirst, yearfirst in DatetimeIndex and hit an unexpected snag: when a freq is passed, we currently pass ambiguous to _validate_frequency, which appears to need it in |
For comparison: pandas-dev/pandas#55856 pandas-dev/pandas#55895 pandas-dev/pandas#55499 The `errors="ignore"` parameter is the only one that is implemented so just added a test for that deprecation Authors: - Matthew Roeschke (https://github.com/mroeschke) - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: #14984
DatetimeIndex.__new__
has constructor keywords (excluding ones present in the base class and ones already deprecated)freq
,tz
,ambiguous
,dayfirst
,yearfirst
.dayfirst
andyearfirst
overlap with thepd.to_datetime
keywords.Could we deprecate some/all of these keywords and point users to
pd.to_datetime
instead?freq
we could either exempt or make a post-construction thing by making_with_freq
public.to_datetime
hasutc
instead oftz
. I generally liketz
better thanutc
as a keyword, but deprecatingutc
might be painful. We could addtz
toto_datetime
and disallow passing tz-and-utc.ambiguous
to to_datetime wouldn't be too bad aside from general keyword fatigue.(similarly
TimedeltaIndex
hasunit
andfreq
,unit
being present inpd.to_timedelta
)cc @MarcoGorelli @mroeschke @jorisvandenbossche
The text was updated successfully, but these errors were encountered: