Skip to content

Commit 01b432c

Browse files
authored
DEPR: Remove deprecated Timestamp.freq (#49365)
* DEPR: Timestamp.freq * __new__, doc * update pickle tests * update docs * update asvs * more whatsnew
1 parent 5a11eb5 commit 01b432c

30 files changed

+119
-458
lines changed

asv_bench/benchmarks/tslibs/timestamp.py

+20-24
Original file line numberDiff line numberDiff line change
@@ -50,62 +50,58 @@ def time_from_pd_timestamp(self):
5050

5151

5252
class TimestampProperties:
53-
_freqs = [None, "B"]
54-
params = [_tzs, _freqs]
55-
param_names = ["tz", "freq"]
53+
params = [_tzs]
54+
param_names = ["tz"]
5655

57-
def setup(self, tz, freq):
58-
self.ts = Timestamp("2017-08-25 08:16:14", tzinfo=tz, freq=freq)
56+
def setup(self, tz):
57+
self.ts = Timestamp("2017-08-25 08:16:14", tzinfo=tz)
5958

60-
def time_tz(self, tz, freq):
59+
def time_tz(self, tz):
6160
self.ts.tz
6261

63-
def time_dayofweek(self, tz, freq):
62+
def time_dayofweek(self, tz):
6463
self.ts.dayofweek
6564

66-
def time_dayofyear(self, tz, freq):
65+
def time_dayofyear(self, tz):
6766
self.ts.dayofyear
6867

69-
def time_week(self, tz, freq):
68+
def time_week(self, tz):
7069
self.ts.week
7170

72-
def time_quarter(self, tz, freq):
71+
def time_quarter(self, tz):
7372
self.ts.quarter
7473

75-
def time_days_in_month(self, tz, freq):
74+
def time_days_in_month(self, tz):
7675
self.ts.days_in_month
7776

78-
def time_freqstr(self, tz, freq):
79-
self.ts.freqstr
80-
81-
def time_is_month_start(self, tz, freq):
77+
def time_is_month_start(self, tz):
8278
self.ts.is_month_start
8379

84-
def time_is_month_end(self, tz, freq):
80+
def time_is_month_end(self, tz):
8581
self.ts.is_month_end
8682

87-
def time_is_quarter_start(self, tz, freq):
83+
def time_is_quarter_start(self, tz):
8884
self.ts.is_quarter_start
8985

90-
def time_is_quarter_end(self, tz, freq):
86+
def time_is_quarter_end(self, tz):
9187
self.ts.is_quarter_end
9288

93-
def time_is_year_start(self, tz, freq):
89+
def time_is_year_start(self, tz):
9490
self.ts.is_year_start
9591

96-
def time_is_year_end(self, tz, freq):
92+
def time_is_year_end(self, tz):
9793
self.ts.is_year_end
9894

99-
def time_is_leap_year(self, tz, freq):
95+
def time_is_leap_year(self, tz):
10096
self.ts.is_leap_year
10197

102-
def time_microsecond(self, tz, freq):
98+
def time_microsecond(self, tz):
10399
self.ts.microsecond
104100

105-
def time_month_name(self, tz, freq):
101+
def time_month_name(self, tz):
106102
self.ts.month_name()
107103

108-
def time_weekday_name(self, tz, freq):
104+
def time_weekday_name(self, tz):
109105
self.ts.day_name()
110106

111107

doc/redirects.csv

-2
Original file line numberDiff line numberDiff line change
@@ -1321,8 +1321,6 @@ generated/pandas.Timestamp.daysinmonth,../reference/api/pandas.Timestamp.daysinm
13211321
generated/pandas.Timestamp.dst,../reference/api/pandas.Timestamp.dst
13221322
generated/pandas.Timestamp.floor,../reference/api/pandas.Timestamp.floor
13231323
generated/pandas.Timestamp.fold,../reference/api/pandas.Timestamp.fold
1324-
generated/pandas.Timestamp.freq,../reference/api/pandas.Timestamp.freq
1325-
generated/pandas.Timestamp.freqstr,../reference/api/pandas.Timestamp.freqstr
13261324
generated/pandas.Timestamp.fromisoformat,../reference/api/pandas.Timestamp.fromisoformat
13271325
generated/pandas.Timestamp.fromordinal,../reference/api/pandas.Timestamp.fromordinal
13281326
generated/pandas.Timestamp.fromtimestamp,../reference/api/pandas.Timestamp.fromtimestamp

doc/source/reference/arrays.rst

-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ Methods
157157
Timestamp.day_name
158158
Timestamp.dst
159159
Timestamp.floor
160-
Timestamp.freq
161-
Timestamp.freqstr
162160
Timestamp.fromordinal
163161
Timestamp.fromtimestamp
164162
Timestamp.isocalendar

doc/source/whatsnew/v0.24.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,7 @@ the object's ``freq`` attribute (:issue:`21939`, :issue:`23878`).
13571357
*New behavior*:
13581358

13591359
.. ipython:: python
1360+
:okexcept:
13601361
:okwarning:
13611362
13621363
ts = pd.Timestamp('1994-05-06 12:15:16', freq=pd.offsets.Hour())

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ Deprecations
250250

251251
Removal of prior version deprecations/changes
252252
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253+
- Removed deprecated :attr:`Timestamp.freq`, :attr:`Timestamp.freqstr` and argument ``freq`` from the :class:`Timestamp` constructor and :meth:`Timestamp.fromordinal` (:issue:`14146`)
253254
- Removed deprecated :class:`CategoricalBlock`, :meth:`Block.is_categorical`, require datetime64 and timedelta64 values to be wrapped in :class:`DatetimeArray` or :class:`TimedeltaArray` before passing to :meth:`Block.make_block_same_class`, require ``DatetimeTZBlock.values`` to have the correct ndim when passing to the :class:`BlockManager` constructor, and removed the "fastpath" keyword from the :class:`SingleBlockManager` constructor (:issue:`40226`, :issue:`40571`)
254255
- Removed deprecated module ``pandas.core.index`` (:issue:`30193`)
255256
- Removed deprecated alias ``pandas.core.tools.datetimes.to_time``, import the function directly from ``pandas.core.tools.times`` instead (:issue:`34145`)

pandas/_libs/tslibs/nattype.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,6 @@ class NaTType(_NaT):
685685
----------
686686
ordinal : int
687687
Date corresponding to a proleptic Gregorian ordinal.
688-
freq : str, DateOffset
689-
Offset to apply to the Timestamp.
690688
tz : str, pytz.timezone, dateutil.tz.tzfile or None
691689
Time zone for the Timestamp.
692690

pandas/_libs/tslibs/timestamps.pxd

-4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ from pandas._libs.tslibs.offsets cimport BaseOffset
1515
cdef _Timestamp create_timestamp_from_ts(int64_t value,
1616
npy_datetimestruct dts,
1717
tzinfo tz,
18-
BaseOffset freq,
1918
bint fold,
2019
NPY_DATETIMEUNIT reso=*)
2120

2221

2322
cdef class _Timestamp(ABCTimestamp):
2423
cdef readonly:
2524
int64_t value, nanosecond, year
26-
BaseOffset _freq
2725
NPY_DATETIMEUNIT _creso
2826

2927
cdef bint _get_start_end_field(self, str field, freq)
@@ -34,7 +32,5 @@ cdef class _Timestamp(ABCTimestamp):
3432
cpdef datetime to_pydatetime(_Timestamp self, bint warn=*)
3533
cdef bint _compare_outside_nanorange(_Timestamp self, datetime other,
3634
int op) except -1
37-
cpdef void _set_freq(self, freq)
38-
cdef _warn_on_field_deprecation(_Timestamp self, freq, str field)
3935
cdef bint _compare_mismatched_resos(_Timestamp self, _Timestamp other, int op)
4036
cdef _Timestamp _as_creso(_Timestamp self, NPY_DATETIMEUNIT reso, bint round_ok=*)

pandas/_libs/tslibs/timestamps.pyi

+1-4
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ class Timestamp(datetime):
4747
tzinfo: _tzinfo | None = ...,
4848
*,
4949
nanosecond: int | None = ...,
50-
freq: int | None | str | BaseOffset = ...,
5150
tz: str | _tzinfo | None | int = ...,
5251
unit: str | int | None = ...,
5352
fold: int | None = ...,
5453
) -> _DatetimeT | NaTType: ...
55-
def _set_freq(self, freq: BaseOffset | None) -> None: ...
5654
@classmethod
5755
def _from_value_and_reso(
5856
cls, value: int, reso: int, tz: _tzinfo | None
@@ -89,7 +87,6 @@ class Timestamp(datetime):
8987
def fromordinal(
9088
cls: type[_DatetimeT],
9189
ordinal: int,
92-
freq: str | BaseOffset | None = ...,
9390
tz: _tzinfo | str | None = ...,
9491
) -> _DatetimeT: ...
9592
@classmethod
@@ -176,7 +173,7 @@ class Timestamp(datetime):
176173
def is_year_end(self) -> bool: ...
177174
def to_pydatetime(self, warn: bool = ...) -> datetime: ...
178175
def to_datetime64(self) -> np.datetime64: ...
179-
def to_period(self, freq: BaseOffset | str | None = ...) -> Period: ...
176+
def to_period(self, freq: BaseOffset | str = ...) -> Period: ...
180177
def to_julian_date(self) -> np.float64: ...
181178
@property
182179
def asm8(self) -> np.datetime64: ...

0 commit comments

Comments
 (0)