Skip to content

Commit 0038bad

Browse files
mroeschkejreback
authored andcommitted
month_name/day_name warnings followup (#20010)
1 parent fd63c90 commit 0038bad

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

pandas/_libs/tslibs/timestamps.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ class Timestamp(_Timestamp):
766766
"""
767767
warnings.warn("`weekday_name` is deprecated and will be removed in a "
768768
"future version. Use `day_name` instead",
769-
DeprecationWarning)
769+
FutureWarning)
770770
return self.day_name()
771771

772772
@property

pandas/tests/indexes/datetimes/test_misc.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ def test_datetime_name_accessors(self, time_locale):
271271
assert dti.weekday_name[day] == eng_name
272272
assert dti.day_name(locale=time_locale)[day] == name
273273
ts = Timestamp(datetime(2016, 4, day))
274-
assert ts.weekday_name == eng_name
274+
with tm.assert_produces_warning(FutureWarning,
275+
check_stacklevel=False):
276+
assert ts.weekday_name == eng_name
275277
assert ts.day_name(locale=time_locale) == name
276278
dti = dti.append(DatetimeIndex([pd.NaT]))
277279
assert np.isnan(dti.day_name(locale=time_locale)[-1])

pandas/tests/indexes/datetimes/test_scalar_compat.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ def test_dti_timestamp_fields(self, field):
4747
# extra fields from DatetimeIndex like quarter and week
4848
idx = tm.makeDateIndex(100)
4949
expected = getattr(idx, field)[-1]
50-
result = getattr(Timestamp(idx[-1]), field)
50+
if field == 'weekday_name':
51+
with tm.assert_produces_warning(FutureWarning,
52+
check_stacklevel=False):
53+
result = getattr(Timestamp(idx[-1]), field)
54+
else:
55+
result = getattr(Timestamp(idx[-1]), field)
5156
assert result == expected
5257

5358
def test_dti_timestamp_freq_fields(self):

pandas/tests/scalar/timestamp/test_timestamp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def check(value, equal):
105105
def test_names(self, data, time_locale):
106106
# GH 17354
107107
# Test .weekday_name, .day_name(), .month_name
108-
with tm.assert_produces_warning(DeprecationWarning,
108+
with tm.assert_produces_warning(FutureWarning,
109109
check_stacklevel=False):
110110
assert data.weekday_name == 'Monday'
111111
if time_locale is None:

0 commit comments

Comments
 (0)