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

DEPR: 'A' in favour of 'Y' #54403

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6e3e96e
DEPR: deprecate codes T and L in to_abbrevs/_abbrev_to_attrnames
natmokval Jul 10, 2023
fe88663
replace T/L with min/ms in _prefix, period_code_map, _attrname_to_abb…
natmokval Jul 12, 2023
1e79480
correct def get_freq for tseries, fix tests
natmokval Jul 14, 2023
f7fd2a1
replace T, L in _offset_to_period_map, is_subperiod, is_superperiod, …
natmokval Jul 14, 2023
98e8a39
correct def to_timedelta, def _round_temporally and fix tests
natmokval Jul 17, 2023
93bbd08
correct def resolution_string, get_reso_from_freqstr and fix tests
natmokval Jul 21, 2023
b0dfd2f
Merge branch 'main' into DEPR-codes-T-L-from-_attrname_to_abbrevs-_ab…
natmokval Jul 21, 2023
51c62a1
fix tests
natmokval Jul 21, 2023
898f811
correct def _maybe_coerce_freq , is_subperiod, is_superperiod, and _o…
natmokval Jul 23, 2023
1d30c07
fix a test for plotting
natmokval Jul 25, 2023
37de346
Merge branch 'main' into DEPR-codes-T-L-from-_attrname_to_abbrevs-_ab…
natmokval Jul 25, 2023
7171237
fix tests
natmokval Jul 25, 2023
29dcd8d
fix failures in asv benchmarks
natmokval Jul 25, 2023
317718a
correct docstrings
natmokval Jul 27, 2023
99a0cf9
deprecate abbrevs U, N add dict depr_abbrevs and fix tests
natmokval Jul 28, 2023
a13a041
correct get_freq and fix tests
natmokval Jul 31, 2023
a949282
Merge branch 'main' into DEPR-codes-T-L-from-_attrname_to_abbrevs-_ab…
natmokval Jul 31, 2023
7bd6188
correct is_superperiod, is_subperiod, _maybe_coerce_freq and fix tests
natmokval Jul 31, 2023
77949c4
correct __eq__ for PeriodDtype
natmokval Aug 1, 2023
a24c0ec
update docstrings
natmokval Aug 1, 2023
733d68b
correct whatsnew and user_guide
natmokval Aug 1, 2023
beeac14
correct tables of Offset/Period aliases in user_guide
natmokval Aug 1, 2023
a3e3522
correct warning message, add the warning to some tests
natmokval Aug 1, 2023
65ddf90
resolve conflicts in tests
natmokval Aug 1, 2023
c61b0fb
add the futurewarning to def asfreq, fix tests
natmokval Aug 1, 2023
c2f45ba
add the futurewarning to to_offset, correct warning message and add t…
natmokval Aug 2, 2023
73405bf
add the warning to parse_timedelta_unit, remove t, l, u, n from timed…
natmokval Aug 2, 2023
b2ab238
correct docstrings, update user_guide for timeseries and add tests
natmokval Aug 2, 2023
4775471
update whatsnew/v2.1.0.rst
natmokval Aug 2, 2023
c3ed691
remove warning from to_timedelta, correct tests
natmokval Aug 3, 2023
828b7d0
deprecate alias A in Timedelta and offsets in favour of Y, fix tests …
natmokval Aug 4, 2023
e97ab53
fix tests [skip ci]
natmokval Aug 4, 2023
21894d9
fix tests and correct docs
natmokval Aug 7, 2023
155b0a7
Merge branch 'main' into DEPR-codes-T-L-from-_attrname_to_abbrevs-_ab…
natmokval Aug 7, 2023
98df303
resolve conflicts
natmokval Aug 7, 2023
4365e23
fix tests and correct user_guide/io.rst
natmokval Aug 7, 2023
705305e
correct user_guide
natmokval Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions asv_bench/benchmarks/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class Timeseries:
def setup(self, tz):
N = 10**6
halfway = (N // 2) - 1
self.s = Series(date_range("20010101", periods=N, freq="T", tz=tz))
self.s = Series(date_range("20010101", periods=N, freq="min", tz=tz))
self.ts = self.s[halfway]

self.s2 = Series(date_range("20010101", periods=N, freq="s", tz=tz))
Expand Down Expand Up @@ -460,7 +460,7 @@ class OffsetArrayArithmetic:

def setup(self, offset):
N = 10000
rng = date_range(start="1/1/2000", periods=N, freq="T")
rng = date_range(start="1/1/2000", periods=N, freq="min")
self.rng = rng
self.ser = Series(rng)

Expand All @@ -479,7 +479,7 @@ class ApplyIndex:

def setup(self, offset):
N = 10000
rng = date_range(start="1/1/2000", periods=N, freq="T")
rng = date_range(start="1/1/2000", periods=N, freq="min")
self.rng = rng

def time_apply_index(self, offset):
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Query:
def setup(self):
N = 10**6
halfway = (N // 2) - 1
index = pd.date_range("20010101", periods=N, freq="T")
index = pd.date_range("20010101", periods=N, freq="min")
s = pd.Series(index)
self.ts = s.iloc[halfway]
self.df = pd.DataFrame({"a": np.random.randn(N), "dates": index}, index=index)
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/gil.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def time_kth_smallest(self):
class ParallelDatetimeFields:
def setup(self):
N = 10**6
self.dti = date_range("1900-01-01", periods=N, freq="T")
self.dti = date_range("1900-01-01", periods=N, freq="min")
self.period = self.dti.to_period("D")

def time_datetime_field_year(self):
Expand Down
6 changes: 3 additions & 3 deletions asv_bench/benchmarks/index_cached_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def setup(self, index_type):
N = 10**5
if index_type == "MultiIndex":
self.idx = pd.MultiIndex.from_product(
[pd.date_range("1/1/2000", freq="T", periods=N // 2), ["a", "b"]]
[pd.date_range("1/1/2000", freq="min", periods=N // 2), ["a", "b"]]
)
elif index_type == "DatetimeIndex":
self.idx = pd.date_range("1/1/2000", freq="T", periods=N)
self.idx = pd.date_range("1/1/2000", freq="min", periods=N)
elif index_type == "Int64Index":
self.idx = pd.Index(range(N), dtype="int64")
elif index_type == "PeriodIndex":
self.idx = pd.period_range("1/1/2000", freq="T", periods=N)
self.idx = pd.period_range("1/1/2000", freq="min", periods=N)
elif index_type == "RangeIndex":
self.idx = pd.RangeIndex(start=0, stop=N)
elif index_type == "IntervalIndex":
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/index_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SetOperations:

def setup(self, index_structure, dtype, method):
N = 10**5
dates_left = date_range("1/1/2000", periods=N, freq="T")
dates_left = date_range("1/1/2000", periods=N, freq="min")
fmt = "%Y-%m-%d %H:%M:%S"
date_str_left = Index(dates_left.strftime(fmt))
int_left = Index(np.arange(N))
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def time_float_longint_str_lines(self):
class ToJSONMem:
def setup_cache(self):
df = DataFrame([[1]])
df2 = DataFrame(range(8), date_range("1/1/2000", periods=8, freq="T"))
df2 = DataFrame(range(8), date_range("1/1/2000", periods=8, freq="min"))
frames = {"int": df, "float": df.astype(float), "datetime": df2}

return frames
Expand Down
4 changes: 2 additions & 2 deletions asv_bench/benchmarks/join_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class JoinNonUnique:
# outer join of non-unique
# GH 6329
def setup(self):
date_index = date_range("01-Jan-2013", "23-Jan-2013", freq="T")
date_index = date_range("01-Jan-2013", "23-Jan-2013", freq="min")
daily_dates = date_index.to_period("D").to_timestamp("S", "S")
self.fracofday = date_index.values - daily_dates.values
self.fracofday = self.fracofday.astype("timedelta64[ns]")
Expand Down Expand Up @@ -338,7 +338,7 @@ class MergeDatetime:
def setup(self, units, tz):
unit_left, unit_right = units
N = 10_000
keys = Series(date_range("2012-01-01", freq="T", periods=N, tz=tz))
keys = Series(date_range("2012-01-01", freq="min", periods=N, tz=tz))
self.left = DataFrame(
{
"key": keys.sample(N * 10, replace=True).dt.as_unit(unit_left),
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SparseSeriesToFrame:
def setup(self):
K = 50
N = 50001
rng = date_range("1/1/2000", periods=N, freq="T")
rng = date_range("1/1/2000", periods=N, freq="min")
self.series = {}
for i in range(1, K):
data = np.random.randn(N)[:-i]
Expand Down
16 changes: 8 additions & 8 deletions asv_bench/benchmarks/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def time_infer_freq(self, freq):
class TimeDatetimeConverter:
def setup(self):
N = 100000
self.rng = date_range(start="1/1/2000", periods=N, freq="T")
self.rng = date_range(start="1/1/2000", periods=N, freq="min")

def time_convert(self):
DatetimeConverter.convert(self.rng, None, None)
Expand All @@ -129,9 +129,9 @@ class Iteration:
def setup(self, time_index):
N = 10**6
if time_index is timedelta_range:
self.idx = time_index(start=0, freq="T", periods=N)
self.idx = time_index(start=0, freq="min", periods=N)
else:
self.idx = time_index(start="20140101", freq="T", periods=N)
self.idx = time_index(start="20140101", freq="min", periods=N)
self.exit = 10000

def time_iter(self, time_index):
Expand All @@ -149,7 +149,7 @@ class ResampleDataFrame:
param_names = ["method"]

def setup(self, method):
rng = date_range(start="20130101", periods=100000, freq="50L")
rng = date_range(start="20130101", periods=100000, freq="50ms")
df = DataFrame(np.random.randn(100000, 2), index=rng)
self.resample = getattr(df.resample("1s"), method)

Expand All @@ -163,8 +163,8 @@ class ResampleSeries:

def setup(self, index, freq, method):
indexes = {
"period": period_range(start="1/1/2000", end="1/1/2001", freq="T"),
"datetime": date_range(start="1/1/2000", end="1/1/2001", freq="T"),
"period": period_range(start="1/1/2000", end="1/1/2001", freq="min"),
"datetime": date_range(start="1/1/2000", end="1/1/2001", freq="min"),
}
idx = indexes[index]
ts = Series(np.random.randn(len(idx)), index=idx)
Expand All @@ -178,7 +178,7 @@ class ResampleDatetetime64:
# GH 7754
def setup(self):
rng3 = date_range(
start="2000-01-01 00:00:00", end="2000-01-01 10:00:00", freq="555000U"
start="2000-01-01 00:00:00", end="2000-01-01 10:00:00", freq="555000us"
)
self.dt_ts = Series(5, rng3, dtype="datetime64[ns]")

Expand Down Expand Up @@ -270,7 +270,7 @@ class DatetimeAccessor:

def setup(self, tz):
N = 100000
self.series = Series(date_range(start="1/1/2000", periods=N, freq="T", tz=tz))
self.series = Series(date_range(start="1/1/2000", periods=N, freq="min", tz=tz))

def time_dt_accessor(self, tz):
self.series.dt
Expand Down
4 changes: 2 additions & 2 deletions asv_bench/benchmarks/tslibs/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def time_to_julian_date(self, tz):
self.ts.to_julian_date()

def time_floor(self, tz):
self.ts.floor("5T")
self.ts.floor("5min")

def time_ceil(self, tz):
self.ts.ceil("5T")
self.ts.ceil("5min")


class TimestampAcrossDst:
Expand Down
13 changes: 9 additions & 4 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2330,10 +2330,15 @@ A few notes on the generated table schema:
same behavior of being converted to UTC. In addition, periods will contain
and additional field ``freq`` with the period's frequency, e.g. ``'A-DEC'``.

.. ipython:: python

s_per = pd.Series(1, index=pd.period_range("2016", freq="A-DEC", periods=4))
build_table_schema(s_per)
.. code-block:: python

In [293]: s_per = pd.Series(1, index=pd.period_range("2016", freq="A-DEC", periods=4))
In [294]: build_table_schema(s_per)
Out[294]:
{'fields': [{'name': 'index', 'type': 'datetime', 'freq': 'A-DEC'},
{'name': 'values', 'type': 'integer'}],
'primaryKey': ['index'],
'pandas_version': '1.4.0'}

* Categoricals use the ``any`` type and an ``enum`` constraint listing
the set of possible values. Additionally, an ``ordered`` field is included:
Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide/scale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Suppose our raw dataset on disk has many columns.
return df

timeseries = [
make_timeseries(freq="1T", seed=i).rename(columns=lambda x: f"{x}_{i}")
make_timeseries(freq="1min", seed=i).rename(columns=lambda x: f"{x}_{i}")
for i in range(10)
]
ts_wide = pd.concat(timeseries, axis=1)
Expand Down Expand Up @@ -173,7 +173,7 @@ files. Each file in the directory represents a different year of the entire data
pathlib.Path("data/timeseries").mkdir(exist_ok=True)

for i, (start, end) in enumerate(zip(starts, ends)):
ts = make_timeseries(start=start, end=end, freq="1T", seed=i)
ts = make_timeseries(start=start, end=end, freq="1min", seed=i)
ts.to_parquet(f"data/timeseries/ts-{i:0>2d}.parquet")


Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/timedeltas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ The ``freq`` parameter can passed a variety of :ref:`frequency aliases <timeseri

.. ipython:: python

pd.timedelta_range(start="1 days", end="2 days", freq="30T")
pd.timedelta_range(start="1 days", end="2 days", freq="30min")

pd.timedelta_range(start="1 days", periods=5, freq="2D5H")

Expand Down
52 changes: 31 additions & 21 deletions doc/source/user_guide/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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``.

.. note::

Expand Down Expand Up @@ -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
Expand All @@ -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
~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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
~~~~~~~~~~~~~~~~~
Expand All @@ -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:

Expand All @@ -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:

Expand All @@ -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.
Expand Down Expand Up @@ -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"]
Expand Down
11 changes: 9 additions & 2 deletions doc/source/whatsnew/v0.13.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,16 @@ Enhancements
Period conversions in the range of seconds and below were reworked and extended
up to nanoseconds. Periods in the nanosecond range are now available.

.. ipython:: python
.. code-block:: python

pd.date_range('2013-01-01', periods=5, freq='5N')
In [79]: pd.date_range('2013-01-01', periods=5, freq='5N')
Out[79]:
DatetimeIndex([ '2013-01-01 00:00:00',
'2013-01-01 00:00:00.000000005',
'2013-01-01 00:00:00.000000010',
'2013-01-01 00:00:00.000000015',
'2013-01-01 00:00:00.000000020'],
dtype='datetime64[ns]', freq='5N')

or with frequency as offset

Expand Down
Loading