Skip to content

DEPR: Remove deprecated Timestamp.freq #49365

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

Merged
merged 12 commits into from
Nov 4, 2022
44 changes: 20 additions & 24 deletions asv_bench/benchmarks/tslibs/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,62 +50,58 @@ def time_from_pd_timestamp(self):


class TimestampProperties:
_freqs = [None, "B"]
params = [_tzs, _freqs]
param_names = ["tz", "freq"]
params = [_tzs]
param_names = ["tz"]

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

def time_tz(self, tz, freq):
def time_tz(self, tz):
self.ts.tz

def time_dayofweek(self, tz, freq):
def time_dayofweek(self, tz):
self.ts.dayofweek

def time_dayofyear(self, tz, freq):
def time_dayofyear(self, tz):
self.ts.dayofyear

def time_week(self, tz, freq):
def time_week(self, tz):
self.ts.week

def time_quarter(self, tz, freq):
def time_quarter(self, tz):
self.ts.quarter

def time_days_in_month(self, tz, freq):
def time_days_in_month(self, tz):
self.ts.days_in_month

def time_freqstr(self, tz, freq):
self.ts.freqstr

def time_is_month_start(self, tz, freq):
def time_is_month_start(self, tz):
self.ts.is_month_start

def time_is_month_end(self, tz, freq):
def time_is_month_end(self, tz):
self.ts.is_month_end

def time_is_quarter_start(self, tz, freq):
def time_is_quarter_start(self, tz):
self.ts.is_quarter_start

def time_is_quarter_end(self, tz, freq):
def time_is_quarter_end(self, tz):
self.ts.is_quarter_end

def time_is_year_start(self, tz, freq):
def time_is_year_start(self, tz):
self.ts.is_year_start

def time_is_year_end(self, tz, freq):
def time_is_year_end(self, tz):
self.ts.is_year_end

def time_is_leap_year(self, tz, freq):
def time_is_leap_year(self, tz):
self.ts.is_leap_year

def time_microsecond(self, tz, freq):
def time_microsecond(self, tz):
self.ts.microsecond

def time_month_name(self, tz, freq):
def time_month_name(self, tz):
self.ts.month_name()

def time_weekday_name(self, tz, freq):
def time_weekday_name(self, tz):
self.ts.day_name()


Expand Down
2 changes: 0 additions & 2 deletions doc/redirects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,6 @@ generated/pandas.Timestamp.daysinmonth,../reference/api/pandas.Timestamp.daysinm
generated/pandas.Timestamp.dst,../reference/api/pandas.Timestamp.dst
generated/pandas.Timestamp.floor,../reference/api/pandas.Timestamp.floor
generated/pandas.Timestamp.fold,../reference/api/pandas.Timestamp.fold
generated/pandas.Timestamp.freq,../reference/api/pandas.Timestamp.freq
generated/pandas.Timestamp.freqstr,../reference/api/pandas.Timestamp.freqstr
generated/pandas.Timestamp.fromisoformat,../reference/api/pandas.Timestamp.fromisoformat
generated/pandas.Timestamp.fromordinal,../reference/api/pandas.Timestamp.fromordinal
generated/pandas.Timestamp.fromtimestamp,../reference/api/pandas.Timestamp.fromtimestamp
Expand Down
2 changes: 0 additions & 2 deletions doc/source/reference/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ Methods
Timestamp.day_name
Timestamp.dst
Timestamp.floor
Timestamp.freq
Timestamp.freqstr
Timestamp.fromordinal
Timestamp.fromtimestamp
Timestamp.isocalendar
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,7 @@ the object's ``freq`` attribute (:issue:`21939`, :issue:`23878`).
*New behavior*:

.. ipython:: python
:okexcept:
:okwarning:

ts = pd.Timestamp('1994-05-06 12:15:16', freq=pd.offsets.Hour())
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ Deprecations

Removal of prior version deprecations/changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Removed deprecated :attr:`Timestamp.freq`, :attr:`Timestamp.freqstr` and argument ``freq`` from the :class:`Timestamp` constructor and :meth:`Timestamp.fromordinal` (:issue:`14146`)
- 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`)
- Removed deprecated module ``pandas.core.index`` (:issue:`30193`)
- Removed deprecated alias ``pandas.core.tools.datetimes.to_time``, import the function directly from ``pandas.core.tools.times`` instead (:issue:`34145`)
Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,6 @@ class NaTType(_NaT):
----------
ordinal : int
Date corresponding to a proleptic Gregorian ordinal.
freq : str, DateOffset
Offset to apply to the Timestamp.
tz : str, pytz.timezone, dateutil.tz.tzfile or None
Time zone for the Timestamp.

Expand Down
4 changes: 0 additions & 4 deletions pandas/_libs/tslibs/timestamps.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ from pandas._libs.tslibs.offsets cimport BaseOffset
cdef _Timestamp create_timestamp_from_ts(int64_t value,
npy_datetimestruct dts,
tzinfo tz,
BaseOffset freq,
bint fold,
NPY_DATETIMEUNIT reso=*)


cdef class _Timestamp(ABCTimestamp):
cdef readonly:
int64_t value, nanosecond, year
BaseOffset _freq
NPY_DATETIMEUNIT _creso

cdef bint _get_start_end_field(self, str field, freq)
Expand All @@ -34,7 +32,5 @@ cdef class _Timestamp(ABCTimestamp):
cpdef datetime to_pydatetime(_Timestamp self, bint warn=*)
cdef bint _compare_outside_nanorange(_Timestamp self, datetime other,
int op) except -1
cpdef void _set_freq(self, freq)
cdef _warn_on_field_deprecation(_Timestamp self, freq, str field)
cdef bint _compare_mismatched_resos(_Timestamp self, _Timestamp other, int op)
cdef _Timestamp _as_creso(_Timestamp self, NPY_DATETIMEUNIT reso, bint round_ok=*)
5 changes: 1 addition & 4 deletions pandas/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ class Timestamp(datetime):
tzinfo: _tzinfo | None = ...,
*,
nanosecond: int | None = ...,
freq: int | None | str | BaseOffset = ...,
tz: str | _tzinfo | None | int = ...,
unit: str | int | None = ...,
fold: int | None = ...,
) -> _DatetimeT | NaTType: ...
def _set_freq(self, freq: BaseOffset | None) -> None: ...
@classmethod
def _from_value_and_reso(
cls, value: int, reso: int, tz: _tzinfo | None
Expand Down Expand Up @@ -89,7 +87,6 @@ class Timestamp(datetime):
def fromordinal(
cls: type[_DatetimeT],
ordinal: int,
freq: str | BaseOffset | None = ...,
tz: _tzinfo | str | None = ...,
) -> _DatetimeT: ...
@classmethod
Expand Down Expand Up @@ -176,7 +173,7 @@ class Timestamp(datetime):
def is_year_end(self) -> bool: ...
def to_pydatetime(self, warn: bool = ...) -> datetime: ...
def to_datetime64(self) -> np.datetime64: ...
def to_period(self, freq: BaseOffset | str | None = ...) -> Period: ...
def to_period(self, freq: BaseOffset | str = ...) -> Period: ...
def to_julian_date(self) -> np.float64: ...
@property
def asm8(self) -> np.datetime64: ...
Expand Down
Loading