Skip to content

cdef out dtype for _Timestamp._get_field #17457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1275,13 +1275,15 @@ cdef class _Timestamp(datetime):
cpdef _get_field(self, field):
cdef:
int64_t val
ndarray[int32_t] out
val = self._maybe_convert_value_to_local()
out = get_date_field(np.array([val], dtype=np.int64), field)
return int(out[0])

cpdef _get_named_field(self, field):
cdef:
int64_t val
ndarray[object] out
val = self._maybe_convert_value_to_local()
out = get_date_name_field(np.array([val], dtype=np.int64), field)
return out[0]
Expand All @@ -1291,9 +1293,7 @@ cdef class _Timestamp(datetime):
'startingMonth', self.freq.kwds.get(
'month', 12)) if self.freq else 12
freqstr = self.freqstr if self.freq else None
val = self.value
if self.tz is not None and not _is_utc(self.tz):
val = tz_convert_single(self.value, 'UTC', self.tz)
val = self._maybe_convert_value_to_local()
out = get_start_end_field(
np.array([val], dtype=np.int64), field, freqstr, month_kw)
return out[0]
Expand Down