Skip to content

Commit 6f39578

Browse files
committed
Lint, move whatsnew, remove hardcoded Monday, check that get_locale is None
1 parent d36ca33 commit 6f39578

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

doc/source/whatsnew/v0.21.1.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Other Enhancements
2222
^^^^^^^^^^^^^^^^^^
2323

2424
- :meth:`Timestamp.timestamp` is now available in Python 2.7. (:issue:`17329`)
25-
- :attr:`Timestamp.month_name`, :attr:`DatetimeIndex.month_name`, and :attr:`Series.dt.month_name` are now available (:issue:`12805`)
25+
-
2626
-
2727

2828
.. _whatsnew_0211.deprecations:
@@ -65,7 +65,7 @@ Bug Fixes
6565
Conversion
6666
^^^^^^^^^^
6767

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

doc/source/whatsnew/v0.22.0.txt

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

2525
- Better support for ``Dataframe.style.to_excel()`` output with the ``xlsxwriter`` engine. (:issue:`16149`)
26-
-
26+
- :attr:`Timestamp.month_name`, :attr:`DatetimeIndex.month_name`, and :attr:`Series.dt.month_name` are now available (:issue:`12805`)
2727
-
2828

2929
.. _whatsnew_0220.api_breaking:
@@ -94,7 +94,7 @@ Bug Fixes
9494
Conversion
9595
^^^^^^^^^^
9696

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

pandas/_libs/tslibs/fields.pyx

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cdef int64_t NPY_NAT = util.get_nat()
3030

3131
from pandas._libs.tslibs.strptime import LocaleTime
3232

33+
3334
def build_field_sarray(ndarray[int64_t] dtindex):
3435
"""
3536
Datetime as int64 representation to a structured array of fields

pandas/tests/indexes/datetimes/test_misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def test_datetimeindex_accessors(self):
328328
assert [d.weekofyear for d in dates] == expected
329329

330330
# GH 12806
331-
@pytest.mark.skipif(len(tm.get_locales()) == 0,
331+
@pytest.mark.skipif(tm.get_locales() is None or len(tm.get_locales()) == 0,
332332
reason='No available locales')
333333
@pytest.mark.parametrize('time_locale', tm.get_locales())
334334
def test_datetime_name_accessors(self, time_locale):

pandas/tests/scalar/test_timestamp.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" test the scalar Timestamp """
22

33
import sys
4+
import locale
45
import pytz
56
import pytest
67
import dateutil
@@ -597,13 +598,17 @@ def check(value, equal):
597598
for end in ends:
598599
assert getattr(ts, end)
599600

600-
@pytest.mark.parametrize('data, expected',
601-
[(Timestamp('2017-08-28 23:00:00'), 'Monday'),
602-
(Timestamp('2017-08-28 23:00:00', tz='EST'),
603-
'Monday')])
604-
def test_weekday_name(self, data, expected):
601+
# GH 12806
602+
@pytest.mark.skipif(tm.get_locales() is None or len(tm.get_locales()) == 0,
603+
reason='No available locales')
604+
@pytest.mark.parametrize('data',
605+
[Timestamp('2017-08-28 23:00:00'),
606+
Timestamp('2017-08-28 23:00:00', tz='EST')])
607+
@pytest.mark.parametrize('time_locale', tm.get_locales())
608+
def test_weekday_name(self, data, time_locale):
605609
# GH 17354
606-
assert data.weekday_name == expected
610+
with tm.set_locale(time_locale, locale.LC_TIME):
611+
assert data.weekday_name == calendar.day_name[0].capitalize()
607612

608613
def test_pprint(self):
609614
# GH12622

0 commit comments

Comments
 (0)