Skip to content

Commit 8a8a4fd

Browse files
mroeschkejreback
authored andcommitted
cdef out dtype for _Timestamp._get_field (#17457)
1 parent 24b440e commit 8a8a4fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/_libs/tslib.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1275,13 +1275,15 @@ cdef class _Timestamp(datetime):
12751275
cpdef _get_field(self, field):
12761276
cdef:
12771277
int64_t val
1278+
ndarray[int32_t] out
12781279
val = self._maybe_convert_value_to_local()
12791280
out = get_date_field(np.array([val], dtype=np.int64), field)
12801281
return int(out[0])
12811282

12821283
cpdef _get_named_field(self, field):
12831284
cdef:
12841285
int64_t val
1286+
ndarray[object] out
12851287
val = self._maybe_convert_value_to_local()
12861288
out = get_date_name_field(np.array([val], dtype=np.int64), field)
12871289
return out[0]
@@ -1291,9 +1293,7 @@ cdef class _Timestamp(datetime):
12911293
'startingMonth', self.freq.kwds.get(
12921294
'month', 12)) if self.freq else 12
12931295
freqstr = self.freqstr if self.freq else None
1294-
val = self.value
1295-
if self.tz is not None and not _is_utc(self.tz):
1296-
val = tz_convert_single(self.value, 'UTC', self.tz)
1296+
val = self._maybe_convert_value_to_local()
12971297
out = get_start_end_field(
12981298
np.array([val], dtype=np.int64), field, freqstr, month_kw)
12991299
return out[0]

0 commit comments

Comments
 (0)