Skip to content

Commit 238f441

Browse files
committed
Fix issues with changing dt.day_name to categorical
1 parent f4ccdeb commit 238f441

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pandas/core/indexes/datetimes.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
from pandas._libs import (lib, index as libindex, tslib as libts,
5757
join as libjoin, Timestamp)
5858
from pandas._libs.tslibs import (timezones, conversion, fields, parsing,
59-
resolution as libresolution)
59+
resolution as libresolution, ccalendar)
6060

6161
# -------- some conversion wrapper functions
6262

@@ -95,10 +95,8 @@ def f(self):
9595
result = self._maybe_mask_results(result, convert='float64')
9696

9797
if field in ['weekday_name', 'day_name']:
98-
cats = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
99-
'Friday', 'Saturday', 'Sunday']
100-
index = CategoricalIndex(result, ordered=True, categories=cats,
101-
name=self.name)
98+
index = CategoricalIndex(result, ordered=True, name=self.name,
99+
categories=ccalendar.DAYS_FULL)
102100
return index
103101
index = Index(result, name=self.name)
104102
return index
@@ -2539,7 +2537,8 @@ def day_name(self, locale=None):
25392537
result = fields.get_date_name_field(values, 'day_name',
25402538
locale=locale)
25412539
result = self._maybe_mask_results(result)
2542-
return Index(result, name=self.name)
2540+
return CategoricalIndex(result, ordered=True, name=self.name,
2541+
categories=ccalendar.DAYS_FULL)
25432542

25442543

25452544
DatetimeIndex._add_comparison_methods()

0 commit comments

Comments
 (0)