Skip to content

Commit de9a2c8

Browse files
mroeschkeproost
authored andcommitted
DEPR: Remove weekday_name (pandas-dev#29831)
* DEPR: Remove weekday_name * Fix documentation
1 parent 102507b commit de9a2c8

File tree

10 files changed

+9
-41
lines changed

10 files changed

+9
-41
lines changed

doc/source/user_guide/timeseries.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ There are several time/date properties that one can access from ``Timestamp`` or
772772
week,"The week ordinal of the year"
773773
dayofweek,"The number of the day of the week with Monday=0, Sunday=6"
774774
weekday,"The number of the day of the week with Monday=0, Sunday=6"
775-
weekday_name,"The name of the day in a week (ex: Friday)"
776775
quarter,"Quarter of the date: Jan-Mar = 1, Apr-Jun = 2, etc."
777776
days_in_month,"The number of days in the month of the datetime"
778777
is_month_start,"Logical indicating if first day of month (defined by frequency)"
@@ -1591,18 +1590,18 @@ labels.
15911590
15921591
s = pd.date_range('2000-01-01', '2000-01-05').to_series()
15931592
s.iloc[2] = pd.NaT
1594-
s.dt.weekday_name
1593+
s.dt.day_name()
15951594
15961595
# default: label='left', closed='left'
1597-
s.resample('B').last().dt.weekday_name
1596+
s.resample('B').last().dt.day_name()
15981597
15991598
Notice how the value for Sunday got pulled back to the previous Friday.
16001599
To get the behavior where the value for Sunday is pushed to Monday, use
16011600
instead
16021601

16031602
.. ipython:: python
16041603
1605-
s.resample('B', label='right', closed='right').last().dt.weekday_name
1604+
s.resample('B', label='right', closed='right').last().dt.day_name()
16061605
16071606
The ``axis`` parameter can be set to 0 or 1 and allows you to resample the
16081607
specified axis for a ``DataFrame``.

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
455455
- Removed previously deprecated keyword "n" from :meth:`DatetimeIndex.shift`, :meth:`TimedeltaIndex.shift`, :meth:`PeriodIndex.shift`, use "periods" instead (:issue:`22458`)
456456
- Changed the default value for the `raw` argument in :func:`Series.rolling().apply() <pandas.core.window.Rolling.apply>`, :func:`DataFrame.rolling().apply() <pandas.core.window.Rolling.apply>`,
457457
- :func:`Series.expanding().apply() <pandas.core.window.Expanding.apply>`, and :func:`DataFrame.expanding().apply() <pandas.core.window.Expanding.apply>` to ``False`` (:issue:`20584`)
458+
- Removed previously deprecated :attr:`Timestamp.weekday_name`, :attr:`DatetimeIndex.weekday_name`, and :attr:`Series.dt.weekday_name` (:issue:`18164`)
458459
-
459460

460461
.. _whatsnew_1000.performance:

pandas/_libs/tslibs/fields.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def build_field_sarray(const int64_t[:] dtindex):
9090
def get_date_name_field(const int64_t[:] dtindex, object field, object locale=None):
9191
"""
9292
Given a int64-based datetime index, return array of strings of date
93-
name based on requested field (e.g. weekday_name)
93+
name based on requested field (e.g. day_name)
9494
"""
9595
cdef:
9696
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
100100

101101
out = np.empty(count, dtype=object)
102102

103-
if field == 'day_name' or field == 'weekday_name':
103+
if field == 'day_name':
104104
if locale is None:
105105
names = np.array(DAYS_FULL, dtype=np.object_)
106106
else:

pandas/_libs/tslibs/nattype.pyx

-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ class NaTType(_NaT):
364364
days_in_month = property(fget=lambda self: np.nan)
365365
daysinmonth = property(fget=lambda self: np.nan)
366366
dayofweek = property(fget=lambda self: np.nan)
367-
weekday_name = property(fget=lambda self: np.nan)
368367

369368
# inject Timedelta properties
370369
days = property(fget=lambda self: np.nan)

pandas/_libs/tslibs/timestamps.pyx

-11
Original file line numberDiff line numberDiff line change
@@ -638,17 +638,6 @@ timedelta}, default 'raise'
638638
"""
639639
return self._get_date_name_field('month_name', locale)
640640

641-
@property
642-
def weekday_name(self) -> str:
643-
"""
644-
.. deprecated:: 0.23.0
645-
Use ``Timestamp.day_name()`` instead
646-
"""
647-
warnings.warn("`weekday_name` is deprecated and will be removed in a "
648-
"future version. Use `day_name` instead",
649-
FutureWarning)
650-
return self.day_name()
651-
652641
@property
653642
def dayofyear(self):
654643
"""

pandas/core/arrays/datetimes.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps, dtl.DatelikeOps
277277
"is_year_end",
278278
"is_leap_year",
279279
]
280-
_object_ops = ["weekday_name", "freq", "tz"]
280+
_object_ops = ["freq", "tz"]
281281
_field_ops = [
282282
"year",
283283
"month",
@@ -1509,14 +1509,6 @@ def date(self):
15091509
dayofweek = _field_accessor("dayofweek", "dow", _dayofweek_doc)
15101510
weekday = dayofweek
15111511

1512-
weekday_name = _field_accessor(
1513-
"weekday_name",
1514-
"weekday_name",
1515-
"""
1516-
The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0
1517-
""",
1518-
)
1519-
15201512
dayofyear = _field_accessor(
15211513
"dayofyear",
15221514
"doy",

pandas/tests/indexes/datetimes/test_misc.py

-4
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ def test_datetimeindex_accessors(self):
200200
assert len(dti.is_quarter_end) == 365
201201
assert len(dti.is_year_start) == 365
202202
assert len(dti.is_year_end) == 365
203-
assert len(dti.weekday_name) == 365
204203

205204
dti.name = "name"
206205

@@ -339,11 +338,8 @@ def test_datetime_name_accessors(self, time_locale):
339338
]
340339
for day, name, eng_name in zip(range(4, 11), expected_days, english_days):
341340
name = name.capitalize()
342-
assert dti.weekday_name[day] == eng_name
343341
assert dti.day_name(locale=time_locale)[day] == name
344342
ts = Timestamp(datetime(2016, 4, day))
345-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
346-
assert ts.weekday_name == eng_name
347343
assert ts.day_name(locale=time_locale) == name
348344
dti = dti.append(DatetimeIndex([pd.NaT]))
349345
assert np.isnan(dti.day_name(locale=time_locale)[-1])

pandas/tests/indexes/datetimes/test_scalar_compat.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,13 @@ def test_dti_date_out_of_range(self, data):
5050
"is_quarter_end",
5151
"is_year_start",
5252
"is_year_end",
53-
"weekday_name",
5453
],
5554
)
5655
def test_dti_timestamp_fields(self, field):
5756
# extra fields from DatetimeIndex like quarter and week
5857
idx = tm.makeDateIndex(100)
5958
expected = getattr(idx, field)[-1]
60-
if field == "weekday_name":
61-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
62-
result = getattr(Timestamp(idx[-1]), field)
63-
else:
64-
result = getattr(Timestamp(idx[-1]), field)
59+
result = getattr(Timestamp(idx[-1]), field)
6560
assert result == expected
6661

6762
def test_dti_timestamp_freq_fields(self):

pandas/tests/scalar/timestamp/test_timestamp.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ def check(value, equal):
108108
)
109109
def test_names(self, data, time_locale):
110110
# GH 17354
111-
# Test .weekday_name, .day_name(), .month_name
112-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
113-
assert data.weekday_name == "Monday"
111+
# Test .day_name(), .month_name
114112
if time_locale is None:
115113
expected_day = "Monday"
116114
expected_month = "August"

pandas/tests/series/test_datetime_values.py

-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ def test_dt_accessor_datetime_name_accessors(self, time_locale):
427427
]
428428
for day, name, eng_name in zip(range(4, 11), expected_days, english_days):
429429
name = name.capitalize()
430-
assert s.dt.weekday_name[day] == eng_name
431430
assert s.dt.day_name(locale=time_locale)[day] == name
432431
s = s.append(Series([pd.NaT]))
433432
assert np.isnan(s.dt.day_name(locale=time_locale).iloc[-1])

0 commit comments

Comments
 (0)