Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Nov 9, 2017
1 parent 1726b5f commit 52a1464
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.21.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Other Enhancements

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

.. _whatsnew_0211.deprecations:

Expand Down Expand Up @@ -65,7 +65,7 @@ Bug Fixes
Conversion
^^^^^^^^^^

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

Expand Down
1 change: 1 addition & 0 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class NaTType(_NaT):
daysinmonth = property(fget=lambda self: np.nan)
dayofweek = property(fget=lambda self: np.nan)
weekday_name = property(fget=lambda self: np.nan)
month_name = property(fget=lambda self: np.nan)

# inject Timedelta properties
days = property(fget=lambda self: np.nan)
Expand Down
29 changes: 17 additions & 12 deletions pandas/tests/indexes/datetimes/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ def test_normalize(self):

class TestDatetime64(object):

# GH 12806
@pytest.mark.parametrize('time_locale', tm.get_locales())
def test_datetimeindex_accessors(self, time_locale):
def test_datetimeindex_accessors(self):
dti_naive = DatetimeIndex(freq='D', start=datetime(1998, 1, 1),
periods=365)
# GH 13303
Expand Down Expand Up @@ -224,14 +222,6 @@ def test_datetimeindex_accessors(self, time_locale):
assert not dti.is_year_end[0]
assert dti.is_year_end[364]

# GH 11128
with tm.set_locale(time_locale, locale.LC_TIME):
for day, name in zip(range(4, 11), calendar.day_name):
# Test Monday -> Sunday
assert dti.weekday_name[day] == name.capitalize()
date = datetime(2016, 4, day)
assert Timestamp(date).weekday_name == name.capitalize()

assert len(dti.year) == 365
assert len(dti.month) == 365
assert len(dti.day) == 365
Expand Down Expand Up @@ -337,9 +327,24 @@ def test_datetimeindex_accessors(self, time_locale):
assert dates.weekofyear.tolist() == expected
assert [d.weekofyear for d in dates] == expected

# GH 12805
# GH 12806
@pytest.mark.skipif(len(tm.get_locales()) == 0,
reason='No available locales')
@pytest.mark.parametrize('time_locale', tm.get_locales())
def test_datetime_name_accessors(self, time_locale):
with tm.set_locale(time_locale, locale.LC_TIME):
# GH 11128
dti = DatetimeIndex(freq='D', start=datetime(1998, 1, 1),
periods=365)
for day, name in zip(range(4, 11), calendar.day_name):
# Test Monday -> Sunday
assert dti.weekday_name[day] == name.capitalize()
date = datetime(2016, 4, day)
assert Timestamp(date).weekday_name == name.capitalize()

# GH 12805
dti = DatetimeIndex(freq='M', start='2012', end='2013')
# Test January -> December
result = dti.month_name
expected = Index([month.capitalize()
for month in calendar.month_name[1:]])
Expand Down

0 comments on commit 52a1464

Please sign in to comment.