diff --git a/pandas/_libs/groupby.pyx b/pandas/_libs/groupby.pyx index a6dbaff17e543..f5f9c06a7e4c2 100644 --- a/pandas/_libs/groupby.pyx +++ b/pandas/_libs/groupby.pyx @@ -243,7 +243,7 @@ def group_shift_indexer(ndarray[int64_t] out, ndarray[int64_t] labels, label_indexer = np.zeros((ngroups, periods), dtype=np.int64) with nogil: for i in range(N): - ## reverse iterator if shifting backwards + # reverse iterator if shifting backwards ii = offset + sign * i lab = labels[ii] diff --git a/pandas/_libs/tslibs/conversion.pyx b/pandas/_libs/tslibs/conversion.pyx index cf5053acb229b..8cfaa1f7b5cea 100644 --- a/pandas/_libs/tslibs/conversion.pyx +++ b/pandas/_libs/tslibs/conversion.pyx @@ -482,7 +482,7 @@ cdef _TSObject convert_str_to_tsobject(object ts, object tz, object unit, cdef inline check_overflows(_TSObject obj): """ Check that we haven't silently overflowed in timezone conversion - + Parameters ---------- obj : _TSObject @@ -577,8 +577,6 @@ cdef inline datetime _localize_pydatetime(datetime dt, tzinfo tz): except AttributeError: return dt.replace(tzinfo=tz) -# ---------------------------------------------------------------------- -# Timezone Conversion cpdef inline datetime localize_pydatetime(datetime dt, object tz): """ @@ -607,6 +605,9 @@ cpdef inline datetime localize_pydatetime(datetime dt, object tz): return dt.replace(tzinfo=tz) +# ---------------------------------------------------------------------- +# Timezone Conversion + cdef inline int64_t tz_convert_tzlocal_to_utc(int64_t val, tzinfo tz): """ Parameters @@ -682,10 +683,8 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2): Returns ------- - int64 converted - + converted: int64 """ - cdef: ndarray[int64_t] trans, deltas Py_ssize_t pos @@ -840,9 +839,17 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None, Localize tzinfo-naive i8 to given time zone (using pytz). If there are ambiguities in the values, raise AmbiguousTimeError. + Parameters + ---------- + vals : ndarray[int64_t] + tz : tzinfo or None + ambiguous : str, bool, or arraylike + If arraylike, must have the same length as vals + errors : {"raise", "coerce"}, default "raise" + Returns ------- - localized : DatetimeIndex + localized : ndarray[int64_t] """ cdef: ndarray[int64_t] trans, deltas, idx_shifted