diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index f5d8a0da0112b..d74673b17c8d9 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -22,14 +22,11 @@ from pandas._libs.tslib import Timestamp, Timedelta from datetime import datetime, timedelta, date from cpython cimport PyTuple_Check, PyList_Check +from cpython.slice cimport PySlice_Check cdef int64_t iNaT = util.get_nat() -cdef extern from "Python.h": - int PySlice_Check(object) - - cdef inline is_definitely_invalid_key(object val): if PyTuple_Check(val): try: diff --git a/pandas/_libs/period.pyx b/pandas/_libs/period.pyx index 272e6f7d38d87..0a1d4a241b795 100644 --- a/pandas/_libs/period.pyx +++ b/pandas/_libs/period.pyx @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # cython: profile=False from datetime import datetime, date, timedelta -import operator from cpython cimport ( PyUnicode_Check, @@ -201,7 +200,7 @@ def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end): Py_ssize_t i, n freq_conv_func func asfreq_info finfo - int64_t val, ordinal + int64_t val char relation n = len(arr) @@ -236,9 +235,6 @@ def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end): def period_ordinal(int y, int m, int d, int h, int min, int s, int us, int ps, int freq): - cdef: - int64_t ordinal - return get_period_ordinal(y, m, d, h, min, s, us, ps, freq) diff --git a/pandas/_libs/tslib.pyx b/pandas/_libs/tslib.pyx index a32f04fe7b156..0777b83de4645 100644 --- a/pandas/_libs/tslib.pyx +++ b/pandas/_libs/tslib.pyx @@ -5,7 +5,7 @@ # distutils: define_macros=CYTHON_TRACE_NOGIL=0 cimport numpy as np -from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray, +from numpy cimport (int32_t, int64_t, import_array, ndarray, float64_t, NPY_DATETIME, NPY_TIMEDELTA) import numpy as np @@ -24,8 +24,6 @@ from cpython cimport ( cdef extern from "Python.h": cdef PyTypeObject *Py_TYPE(object) -from libc.stdlib cimport free - from util cimport (is_integer_object, is_float_object, is_string_object, is_datetime64_object, is_timedelta64_object, INT64_MAX) @@ -51,7 +49,6 @@ from tslibs.np_datetime cimport (check_dts_bounds, PANDAS_DATETIMEUNIT, PANDAS_FR_ns, dt64_to_dtstruct, dtstruct_to_dt64, pydatetime_to_dt64, pydate_to_dt64, - npy_datetime, get_datetime64_unit, get_datetime64_value, get_timedelta64_value, days_per_month_table, @@ -75,12 +72,10 @@ from tslibs.timedeltas cimport cast_from_unit, delta_to_nanoseconds from tslibs.timedeltas import Timedelta from tslibs.timezones cimport ( is_utc, is_tzlocal, is_fixed_offset, - treat_tz_as_dateutil, treat_tz_as_pytz, - get_timezone, get_utcoffset, maybe_get_tz, + treat_tz_as_pytz, + get_timezone, maybe_get_tz, get_dst_info) -from tslibs.fields import ( - get_date_name_field, get_start_end_field, get_date_field, - build_field_sarray) +from tslibs.fields import get_start_end_field, get_date_field from tslibs.conversion cimport (tz_convert_single, _TSObject, convert_to_tsobject, convert_datetime_to_tsobject, @@ -1763,13 +1758,6 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise', return oresult -cdef PyTypeObject* td_type = Timedelta - - -cdef inline bint is_timedelta(object o): - return Py_TYPE(o) == td_type # isinstance(o, Timedelta) - - # ---------------------------------------------------------------------- # Conversion routines diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index b0e22460fdcb0..ba96979435f81 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -55,7 +55,7 @@ from pandas._libs import (lib, index as libindex, tslib as libts, algos as libalgos, join as libjoin, Timestamp, period as libperiod) -from pandas._libs.tslibs import timezones, conversion +from pandas._libs.tslibs import timezones, conversion, fields # -------- some conversion wrapper functions @@ -75,20 +75,20 @@ def f(self): self.freq.kwds.get('month', 12)) if self.freq else 12) - result = libts.get_start_end_field(values, field, self.freqstr, - month_kw) + result = fields.get_start_end_field(values, field, + self.freqstr, month_kw) else: - result = libts.get_date_field(values, field) + result = fields.get_date_field(values, field) # these return a boolean by-definition return result if field in self._object_ops: - result = libts.get_date_name_field(values, field) + result = fields.get_date_name_field(values, field) result = self._maybe_mask_results(result) else: - result = libts.get_date_field(values, field) + result = fields.get_date_field(values, field) result = self._maybe_mask_results(result, convert='float64') return Index(result, name=self.name)