Skip to content

Commit d36ca33

Browse files
committed
Address comments
1 parent bc4ccc4 commit d36ca33

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

doc/source/whatsnew/v0.21.1.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Other Enhancements
2323

2424
- :meth:`Timestamp.timestamp` is now available in Python 2.7. (:issue:`17329`)
2525
- :attr:`Timestamp.month_name`, :attr:`DatetimeIndex.month_name`, and :attr:`Series.dt.month_name` are now available (:issue:`12805`)
26-
- ``month_name` and ``weekday_name`` attributes will now return locale aware values (:issue:`12806`)
26+
-
2727

2828
.. _whatsnew_0211.deprecations:
2929

@@ -65,7 +65,7 @@ Bug Fixes
6565
Conversion
6666
^^^^^^^^^^
6767

68-
-
68+
- Bug in :attr:`Timestamp.weekday_name` and :attr:`DatetimeIndex.weekday_name` not returning locale aware values (:issue:`12806`)
6969
-
7070
-
7171

pandas/_libs/tslibs/nattype.pyx

+1
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class NaTType(_NaT):
301301
daysinmonth = property(fget=lambda self: np.nan)
302302
dayofweek = property(fget=lambda self: np.nan)
303303
weekday_name = property(fget=lambda self: np.nan)
304+
month_name = property(fget=lambda self: np.nan)
304305

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

pandas/tests/indexes/datetimes/test_misc.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ def test_normalize(self):
175175

176176
class TestDatetime64(object):
177177

178-
# GH 12806
179-
@pytest.mark.parametrize('time_locale', tm.get_locales())
180-
def test_datetimeindex_accessors(self, time_locale):
178+
def test_datetimeindex_accessors(self):
181179
dti_naive = DatetimeIndex(freq='D', start=datetime(1998, 1, 1),
182180
periods=365)
183181
# GH 13303
@@ -224,14 +222,6 @@ def test_datetimeindex_accessors(self, time_locale):
224222
assert not dti.is_year_end[0]
225223
assert dti.is_year_end[364]
226224

227-
# GH 11128
228-
with tm.set_locale(time_locale, locale.LC_TIME):
229-
for day, name in zip(range(4, 11), calendar.day_name):
230-
# Test Monday -> Sunday
231-
assert dti.weekday_name[day] == name.capitalize()
232-
date = datetime(2016, 4, day)
233-
assert Timestamp(date).weekday_name == name.capitalize()
234-
235225
assert len(dti.year) == 365
236226
assert len(dti.month) == 365
237227
assert len(dti.day) == 365
@@ -337,9 +327,24 @@ def test_datetimeindex_accessors(self, time_locale):
337327
assert dates.weekofyear.tolist() == expected
338328
assert [d.weekofyear for d in dates] == expected
339329

340-
# GH 12805
330+
# GH 12806
331+
@pytest.mark.skipif(len(tm.get_locales()) == 0,
332+
reason='No available locales')
333+
@pytest.mark.parametrize('time_locale', tm.get_locales())
334+
def test_datetime_name_accessors(self, time_locale):
341335
with tm.set_locale(time_locale, locale.LC_TIME):
336+
# GH 11128
337+
dti = DatetimeIndex(freq='D', start=datetime(1998, 1, 1),
338+
periods=365)
339+
for day, name in zip(range(4, 11), calendar.day_name):
340+
# Test Monday -> Sunday
341+
assert dti.weekday_name[day] == name.capitalize()
342+
date = datetime(2016, 4, day)
343+
assert Timestamp(date).weekday_name == name.capitalize()
344+
345+
# GH 12805
342346
dti = DatetimeIndex(freq='M', start='2012', end='2013')
347+
# Test January -> December
343348
result = dti.month_name
344349
expected = Index([month.capitalize()
345350
for month in calendar.month_name[1:]])

0 commit comments

Comments
 (0)