-
-
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
DEPR: deprecate strings T, S, L, U, and N in offsets frequencies, resolution abbreviations, _attrname_to_abbrevs #54061
Changes from 31 commits
6e3e96e
fe88663
1e79480
f7fd2a1
98e8a39
93bbd08
b0dfd2f
51c62a1
898f811
1d30c07
37de346
7171237
29dcd8d
317718a
99a0cf9
a13a041
a949282
7bd6188
77949c4
a24c0ec
733d68b
beeac14
a3e3522
65ddf90
c61b0fb
c2f45ba
73405bf
b2ab238
4775471
c3ed691
155b0a7
31d292c
d5dabd0
9cf0565
609646e
cc04261
93533d9
9ba1734
b79e9b6
3408d0b
12888f8
cdd5f6b
c7b8b24
5bb2ca8
c54e431
0966d2f
271bd6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -603,7 +603,7 @@ would include matching times on an included date: | |
dft = pd.DataFrame( | ||
np.random.randn(100000, 1), | ||
columns=["A"], | ||
index=pd.date_range("20130101", periods=100000, freq="T"), | ||
index=pd.date_range("20130101", periods=100000, freq="min"), | ||
) | ||
dft | ||
dft.loc["2013"] | ||
|
@@ -905,11 +905,11 @@ into ``freq`` keyword arguments. The available date offsets and associated frequ | |
:class:`~pandas.tseries.offsets.CustomBusinessHour`, ``'CBH'``, "custom business hour" | ||
:class:`~pandas.tseries.offsets.Day`, ``'D'``, "one absolute day" | ||
:class:`~pandas.tseries.offsets.Hour`, ``'H'``, "one hour" | ||
:class:`~pandas.tseries.offsets.Minute`, ``'T'`` or ``'min'``,"one minute" | ||
:class:`~pandas.tseries.offsets.Minute`, ``'min'``,"one minute" | ||
:class:`~pandas.tseries.offsets.Second`, ``'S'``, "one second" | ||
:class:`~pandas.tseries.offsets.Milli`, ``'L'`` or ``'ms'``, "one millisecond" | ||
:class:`~pandas.tseries.offsets.Micro`, ``'U'`` or ``'us'``, "one microsecond" | ||
:class:`~pandas.tseries.offsets.Nano`, ``'N'``, "one nanosecond" | ||
:class:`~pandas.tseries.offsets.Milli`, ``'ms'``, "one millisecond" | ||
:class:`~pandas.tseries.offsets.Micro`, ``'us'``, "one microsecond" | ||
:class:`~pandas.tseries.offsets.Nano`, ``'ns'``, "one nanosecond" | ||
|
||
``DateOffsets`` additionally have :meth:`rollforward` and :meth:`rollback` | ||
methods for moving a date forward or backward respectively to a valid offset | ||
|
@@ -1264,11 +1264,16 @@ frequencies. We will refer to these aliases as *offset aliases*. | |
"BAS, BYS", "business year start frequency" | ||
"BH", "business hour frequency" | ||
"H", "hourly frequency" | ||
"T, min", "minutely frequency" | ||
"min", "minutely frequency" | ||
"S", "secondly frequency" | ||
"L, ms", "milliseconds" | ||
"U, us", "microseconds" | ||
"N", "nanoseconds" | ||
"ms", "milliseconds" | ||
"us", "microseconds" | ||
"ns", "nanoseconds" | ||
|
||
.. deprecated:: 2.1.0 | ||
|
||
Aliases ``T``, ``L``, ``U``, and ``N`` are deprecated in favour of the aliases | ||
``min``, ``ms``, ``us``, and ``ns``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks fine to me, I think it's a better experience if the list of aliases above teaches the new behaviour to begin with - but OK with adding |
||
|
||
.. note:: | ||
|
||
|
@@ -1318,11 +1323,16 @@ frequencies. We will refer to these aliases as *period aliases*. | |
"Q", "quarterly frequency" | ||
"A, Y", "yearly frequency" | ||
"H", "hourly frequency" | ||
"T, min", "minutely frequency" | ||
"min", "minutely frequency" | ||
"S", "secondly frequency" | ||
"L, ms", "milliseconds" | ||
"U, us", "microseconds" | ||
"N", "nanoseconds" | ||
"ms", "milliseconds" | ||
"us", "microseconds" | ||
"ns", "nanoseconds" | ||
|
||
.. deprecated:: 2.1.0 | ||
|
||
Aliases ``T``, ``L``, ``U``, and ``N`` are deprecated in favour of the aliases | ||
``min``, ``ms``, ``us``, and ``ns``. | ||
|
||
|
||
Combining aliases | ||
|
@@ -1343,7 +1353,7 @@ You can combine together day and intraday offsets: | |
|
||
pd.date_range(start, periods=10, freq="2h20min") | ||
|
||
pd.date_range(start, periods=10, freq="1D10U") | ||
pd.date_range(start, periods=10, freq="1D10us") | ||
|
||
Anchored offsets | ||
~~~~~~~~~~~~~~~~ | ||
|
@@ -1725,11 +1735,11 @@ For upsampling, you can specify a way to upsample and the ``limit`` parameter to | |
|
||
# from secondly to every 250 milliseconds | ||
|
||
ts[:2].resample("250L").asfreq() | ||
ts[:2].resample("250ms").asfreq() | ||
|
||
ts[:2].resample("250L").ffill() | ||
ts[:2].resample("250ms").ffill() | ||
|
||
ts[:2].resample("250L").ffill(limit=2) | ||
ts[:2].resample("250ms").ffill(limit=2) | ||
|
||
Sparse resampling | ||
~~~~~~~~~~~~~~~~~ | ||
|
@@ -1752,7 +1762,7 @@ If we want to resample to the full range of the series: | |
|
||
.. ipython:: python | ||
|
||
ts.resample("3T").sum() | ||
ts.resample("3min").sum() | ||
|
||
We can instead only resample those groups where we have points as follows: | ||
|
||
|
@@ -1766,7 +1776,7 @@ We can instead only resample those groups where we have points as follows: | |
freq = to_offset(freq) | ||
return pd.Timestamp((t.value // freq.delta.value) * freq.delta.value) | ||
|
||
ts.groupby(partial(round, freq="3T")).sum() | ||
ts.groupby(partial(round, freq="3min")).sum() | ||
|
||
.. _timeseries.aggregate: | ||
|
||
|
@@ -1786,7 +1796,7 @@ Resampling a ``DataFrame``, the default will be to act on all columns with the s | |
index=pd.date_range("1/1/2012", freq="S", periods=1000), | ||
columns=["A", "B", "C"], | ||
) | ||
r = df.resample("3T") | ||
r = df.resample("3min") | ||
r.mean() | ||
|
||
We can select a specific column or columns using standard getitem. | ||
|
@@ -2155,7 +2165,7 @@ Passing a string representing a lower frequency than ``PeriodIndex`` returns par | |
dfp = pd.DataFrame( | ||
np.random.randn(600, 1), | ||
columns=["A"], | ||
index=pd.period_range("2013-01-01 9:00", periods=600, freq="T"), | ||
index=pd.period_range("2013-01-01 9:00", periods=600, freq="min"), | ||
) | ||
dfp | ||
dfp.loc["2013-01-01 10H"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -549,6 +549,9 @@ Other Deprecations | |
- Deprecated parameter ``obj`` in :meth:`GroupBy.get_group` (:issue:`53545`) | ||
- Deprecated positional indexing on :class:`Series` with :meth:`Series.__getitem__` and :meth:`Series.__setitem__`, in a future version ``ser[item]`` will *always* interpret ``item`` as a label, not a position (:issue:`50617`) | ||
- Deprecated replacing builtin and NumPy functions in ``.agg``, ``.apply``, and ``.transform``; use the corresponding string alias (e.g. ``"sum"`` for ``sum`` or ``np.sum``) instead (:issue:`53425`) | ||
- Deprecated strings ``T``, ``L``, ``U``, and ``N`` denoting aliases for time series frequencies. Please use ``min``, ``ms``, ``us``, and ``ns`` instead of ``T``, ``L``, ``U``, and ``N`` (:issue:`52536`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we specify what functions/methods are relevant here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think we should. I’ll do that. |
||
- Deprecated strings ``T``, ``L``, ``U``, and ``N`` denoting resolutions in :meth:`Timedelta.resolution_string`. Please use ``min``, ``ms``, ``us``, and ``ns`` instead of ``T``, ``L``, ``U``, and ``N`` (:issue:`52536`) | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Deprecated strings ``T``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta`. Please use ``min``, ``ms``, ``us``, and ``ns`` instead of ``T``, ``L``, ``U``, and ``N`` (:issue:`52536`) | ||
- Deprecated strings ``T``, ``t``, ``L`` and ``l`` denoting units in :func:`to_timedelta` (:issue:`52536`) | ||
- Deprecated the "method" and "limit" keywords in ``ExtensionArray.fillna``, implement and use ``pad_or_backfill`` instead (:issue:`53621`) | ||
- Deprecated the "method" and "limit" keywords on :meth:`Series.fillna`, :meth:`DataFrame.fillna`, :meth:`SeriesGroupBy.fillna`, :meth:`DataFrameGroupBy.fillna`, and :meth:`Resampler.fillna`, use ``obj.bfill()`` or ``obj.ffill()`` instead (:issue:`53394`) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need changing in this PR (can be done as a follow-up, there's plenty of time until pandas 2.2), but if we're doing these renamings, then 'H' should probably be renamed too (and CBH, and BH)
I'd stop there - then there a simple rule: anything sub-daily is lowercase, anything daily or higher is upper-case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the comments. I agree, it would be better to rename 'H', 'CBH', and 'BH' too, I'll do it in a separate PR. I like the idea to keep anything sub-daily lowercase, and daily or higher upper-case.