Skip to content

Commit

Permalink
Move some imports to top of file, remove dup implimention of day_name…
Browse files Browse the repository at this point in the history
… in fields
  • Loading branch information
mroeschke committed Feb 25, 2018
1 parent 3b79e2a commit 616665a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
5 changes: 3 additions & 2 deletions pandas/_libs/tslibs/ccalendar.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ cimport numpy as cnp
from numpy cimport int64_t, int32_t
cnp.import_array()

import locale
from strptime import LocaleTime

# ----------------------------------------------------------------------
# Constants
Expand Down Expand Up @@ -225,9 +227,8 @@ cpdef get_locale_names(object name_type, object time_locale=None):
cdef:
list locale_names

import locale
from pandas.util.testing import set_locale
from strptime import LocaleTime

with set_locale(time_locale, locale.LC_TIME):
locale_names = getattr(LocaleTime(), name_type)
return locale_names
13 changes: 1 addition & 12 deletions pandas/_libs/tslibs/fields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,7 @@ def get_date_name_field(ndarray[int64_t] dtindex, object field,
count = len(dtindex)
out = np.empty(count, dtype=object)

if field == 'weekday_name':
_dayname = np.array(DAYS_FULL, dtype=np.object_)
for i in range(count):
if dtindex[i] == NPY_NAT:
out[i] = np.nan
continue

dt64_to_dtstruct(dtindex[i], &dts)
dow = dayofweek(dts.year, dts.month, dts.day)
out[i] = _dayname[dow]
return out
elif field == 'day_name':
if field == 'day_name':
if time_locale is None:
_dayname = np.array(DAYS_FULL, dtype=np.object_)
else:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def _add_comparison_methods(cls):
_bool_ops = ['is_month_start', 'is_month_end',
'is_quarter_start', 'is_quarter_end', 'is_year_start',
'is_year_end', 'is_leap_year']
_object_ops = ['weekday_name', 'freq', 'tz']
_object_ops = ['weekday_name', 'day_name', 'freq', 'tz']
_field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second',
'weekofyear', 'week', 'weekday', 'dayofweek',
'dayofyear', 'quarter', 'days_in_month',
Expand Down Expand Up @@ -1720,7 +1720,7 @@ def freq(self, value):

weekday_name = _field_accessor(
'weekday_name',
'weekday_name',
'day_name',
"The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0")

dayofyear = _field_accessor('dayofyear', 'doy',
Expand Down

0 comments on commit 616665a

Please sign in to comment.