diff --git a/doc/source/user_guide/timeseries.rst b/doc/source/user_guide/timeseries.rst index 17b02374050d29..08b2ae0a4a8376 100644 --- a/doc/source/user_guide/timeseries.rst +++ b/doc/source/user_guide/timeseries.rst @@ -772,7 +772,6 @@ There are several time/date properties that one can access from ``Timestamp`` or week,"The week ordinal of the year" dayofweek,"The number of the day of the week with Monday=0, Sunday=6" weekday,"The number of the day of the week with Monday=0, Sunday=6" - weekday_name,"The name of the day in a week (ex: Friday)" quarter,"Quarter of the date: Jan-Mar = 1, Apr-Jun = 2, etc." days_in_month,"The number of days in the month of the datetime" is_month_start,"Logical indicating if first day of month (defined by frequency)" @@ -1591,10 +1590,10 @@ labels. s = pd.date_range('2000-01-01', '2000-01-05').to_series() s.iloc[2] = pd.NaT - s.dt.weekday_name + s.dt.day_name() # default: label='left', closed='left' - s.resample('B').last().dt.weekday_name + s.resample('B').last().dt.day_name() Notice how the value for Sunday got pulled back to the previous Friday. To get the behavior where the value for Sunday is pushed to Monday, use @@ -1602,7 +1601,7 @@ labels. .. ipython:: python - s.resample('B', label='right', closed='right').last().dt.weekday_name + s.resample('B', label='right', closed='right').last().dt.day_name() The ``axis`` parameter can be set to 0 or 1 and allows you to resample the specified axis for a ``DataFrame``. diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index d01a5fb4f8b433..8a9b9db140409c 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -455,6 +455,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Removed previously deprecated keyword "n" from :meth:`DatetimeIndex.shift`, :meth:`TimedeltaIndex.shift`, :meth:`PeriodIndex.shift`, use "periods" instead (:issue:`22458`) - Changed the default value for the `raw` argument in :func:`Series.rolling().apply() `, :func:`DataFrame.rolling().apply() `, - :func:`Series.expanding().apply() `, and :func:`DataFrame.expanding().apply() ` to ``False`` (:issue:`20584`) +- Removed previously deprecated :attr:`Timestamp.weekday_name`, :attr:`DatetimeIndex.weekday_name`, and :attr:`Series.dt.weekday_name` (:issue:`18164`) - .. _whatsnew_1000.performance: diff --git a/pandas/_libs/tslibs/fields.pyx b/pandas/_libs/tslibs/fields.pyx index dfed8d06530aa7..8bee7da6231baa 100644 --- a/pandas/_libs/tslibs/fields.pyx +++ b/pandas/_libs/tslibs/fields.pyx @@ -90,7 +90,7 @@ def build_field_sarray(const int64_t[:] dtindex): def get_date_name_field(const int64_t[:] dtindex, object field, object locale=None): """ Given a int64-based datetime index, return array of strings of date - name based on requested field (e.g. weekday_name) + name based on requested field (e.g. day_name) """ cdef: Py_ssize_t i, count = len(dtindex) @@ -100,7 +100,7 @@ def get_date_name_field(const int64_t[:] dtindex, object field, object locale=No out = np.empty(count, dtype=object) - if field == 'day_name' or field == 'weekday_name': + if field == 'day_name': if locale is None: names = np.array(DAYS_FULL, dtype=np.object_) else: diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 6fab827f1364ab..966f72dcd78893 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -364,7 +364,6 @@ class NaTType(_NaT): days_in_month = property(fget=lambda self: np.nan) daysinmonth = property(fget=lambda self: np.nan) dayofweek = property(fget=lambda self: np.nan) - weekday_name = property(fget=lambda self: np.nan) # inject Timedelta properties days = property(fget=lambda self: np.nan) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index bb136e1f803868..08e504ada789e7 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -638,17 +638,6 @@ timedelta}, default 'raise' """ return self._get_date_name_field('month_name', locale) - @property - def weekday_name(self) -> str: - """ - .. deprecated:: 0.23.0 - Use ``Timestamp.day_name()`` instead - """ - warnings.warn("`weekday_name` is deprecated and will be removed in a " - "future version. Use `day_name` instead", - FutureWarning) - return self.day_name() - @property def dayofyear(self): """ diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index fc3899bc615557..07cbaa8cd1eb6e 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -277,7 +277,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps, dtl.DatelikeOps "is_year_end", "is_leap_year", ] - _object_ops = ["weekday_name", "freq", "tz"] + _object_ops = ["freq", "tz"] _field_ops = [ "year", "month", @@ -1509,14 +1509,6 @@ def date(self): dayofweek = _field_accessor("dayofweek", "dow", _dayofweek_doc) weekday = dayofweek - weekday_name = _field_accessor( - "weekday_name", - "weekday_name", - """ - The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0 - """, - ) - dayofyear = _field_accessor( "dayofyear", "doy", diff --git a/pandas/tests/indexes/datetimes/test_misc.py b/pandas/tests/indexes/datetimes/test_misc.py index ab3107a0798e5a..c144f2a447ed32 100644 --- a/pandas/tests/indexes/datetimes/test_misc.py +++ b/pandas/tests/indexes/datetimes/test_misc.py @@ -200,7 +200,6 @@ def test_datetimeindex_accessors(self): assert len(dti.is_quarter_end) == 365 assert len(dti.is_year_start) == 365 assert len(dti.is_year_end) == 365 - assert len(dti.weekday_name) == 365 dti.name = "name" @@ -339,11 +338,8 @@ def test_datetime_name_accessors(self, time_locale): ] for day, name, eng_name in zip(range(4, 11), expected_days, english_days): name = name.capitalize() - assert dti.weekday_name[day] == eng_name assert dti.day_name(locale=time_locale)[day] == name ts = Timestamp(datetime(2016, 4, day)) - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - assert ts.weekday_name == eng_name assert ts.day_name(locale=time_locale) == name dti = dti.append(DatetimeIndex([pd.NaT])) assert np.isnan(dti.day_name(locale=time_locale)[-1]) diff --git a/pandas/tests/indexes/datetimes/test_scalar_compat.py b/pandas/tests/indexes/datetimes/test_scalar_compat.py index 00310f4fba7c74..62383555f60489 100644 --- a/pandas/tests/indexes/datetimes/test_scalar_compat.py +++ b/pandas/tests/indexes/datetimes/test_scalar_compat.py @@ -50,18 +50,13 @@ def test_dti_date_out_of_range(self, data): "is_quarter_end", "is_year_start", "is_year_end", - "weekday_name", ], ) def test_dti_timestamp_fields(self, field): # extra fields from DatetimeIndex like quarter and week idx = tm.makeDateIndex(100) expected = getattr(idx, field)[-1] - if field == "weekday_name": - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - result = getattr(Timestamp(idx[-1]), field) - else: - result = getattr(Timestamp(idx[-1]), field) + result = getattr(Timestamp(idx[-1]), field) assert result == expected def test_dti_timestamp_freq_fields(self): diff --git a/pandas/tests/scalar/timestamp/test_timestamp.py b/pandas/tests/scalar/timestamp/test_timestamp.py index f9fa80644d4b98..a33afc8b3ccca9 100644 --- a/pandas/tests/scalar/timestamp/test_timestamp.py +++ b/pandas/tests/scalar/timestamp/test_timestamp.py @@ -108,9 +108,7 @@ def check(value, equal): ) def test_names(self, data, time_locale): # GH 17354 - # Test .weekday_name, .day_name(), .month_name - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - assert data.weekday_name == "Monday" + # Test .day_name(), .month_name if time_locale is None: expected_day = "Monday" expected_month = "August" diff --git a/pandas/tests/series/test_datetime_values.py b/pandas/tests/series/test_datetime_values.py index d038df1747f73e..aa56131f055704 100644 --- a/pandas/tests/series/test_datetime_values.py +++ b/pandas/tests/series/test_datetime_values.py @@ -427,7 +427,6 @@ def test_dt_accessor_datetime_name_accessors(self, time_locale): ] for day, name, eng_name in zip(range(4, 11), expected_days, english_days): name = name.capitalize() - assert s.dt.weekday_name[day] == eng_name assert s.dt.day_name(locale=time_locale)[day] == name s = s.append(Series([pd.NaT])) assert np.isnan(s.dt.day_name(locale=time_locale).iloc[-1])