Skip to content

Commit e1ea051

Browse files
committed
Move some imports to top of file, remove dup implimention of day_name in fields
1 parent 7e7ea7d commit e1ea051

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

pandas/_libs/tslibs/ccalendar.pyx

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ cimport numpy as cnp
1212
from numpy cimport int64_t, int32_t
1313
cnp.import_array()
1414

15+
import locale
16+
from strptime import LocaleTime
1517

1618
# ----------------------------------------------------------------------
1719
# Constants
@@ -225,9 +227,8 @@ cpdef get_locale_names(object name_type, object time_locale=None):
225227
cdef:
226228
list locale_names
227229

228-
import locale
229230
from pandas.util.testing import set_locale
230-
from strptime import LocaleTime
231+
231232
with set_locale(time_locale, locale.LC_TIME):
232233
locale_names = getattr(LocaleTime(), name_type)
233234
return locale_names

pandas/_libs/tslibs/fields.pyx

+1-12
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,7 @@ def get_date_name_field(ndarray[int64_t] dtindex, object field,
100100
count = len(dtindex)
101101
out = np.empty(count, dtype=object)
102102

103-
if field == 'weekday_name':
104-
_dayname = np.array(DAYS_FULL, dtype=np.object_)
105-
for i in range(count):
106-
if dtindex[i] == NPY_NAT:
107-
out[i] = np.nan
108-
continue
109-
110-
dt64_to_dtstruct(dtindex[i], &dts)
111-
dow = dayofweek(dts.year, dts.month, dts.day)
112-
out[i] = _dayname[dow]
113-
return out
114-
elif field == 'day_name':
103+
if field == 'day_name':
115104
if time_locale is None:
116105
_dayname = np.array(DAYS_FULL, dtype=np.object_)
117106
else:

pandas/core/indexes/datetimes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def _add_comparison_methods(cls):
311311
_bool_ops = ['is_month_start', 'is_month_end',
312312
'is_quarter_start', 'is_quarter_end', 'is_year_start',
313313
'is_year_end', 'is_leap_year']
314-
_object_ops = ['weekday_name', 'freq', 'tz']
314+
_object_ops = ['weekday_name', 'day_name', 'freq', 'tz']
315315
_field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second',
316316
'weekofyear', 'week', 'weekday', 'dayofweek',
317317
'dayofyear', 'quarter', 'days_in_month',
@@ -1720,7 +1720,7 @@ def freq(self, value):
17201720

17211721
weekday_name = _field_accessor(
17221722
'weekday_name',
1723-
'weekday_name',
1723+
'day_name',
17241724
"The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0")
17251725

17261726
dayofyear = _field_accessor('dayofyear', 'doy',

0 commit comments

Comments
 (0)