From fa1bd33f8a366e1400f156058d3f6eecf9861327 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Tue, 3 Jul 2018 09:05:49 -0700 Subject: [PATCH 1/2] docstring and whitespace cleanup --- pandas/_libs/groupby.pyx | 2 +- pandas/_libs/tslibs/conversion.pyx | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) 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..27db4bcdc3ae7 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 @@ -682,10 +682,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 +838,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 From 1fe67a26d81a5b1e3505df1403fcdf05ba274343 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Tue, 3 Jul 2018 09:14:07 -0700 Subject: [PATCH 2/2] fix separator location --- pandas/_libs/tslibs/conversion.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/conversion.pyx b/pandas/_libs/tslibs/conversion.pyx index 27db4bcdc3ae7..8cfaa1f7b5cea 100644 --- a/pandas/_libs/tslibs/conversion.pyx +++ b/pandas/_libs/tslibs/conversion.pyx @@ -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