diff --git a/pandas/_libs/src/datetime/np_datetime.c b/pandas/_libs/src/datetime/np_datetime.c index 11e1e6522ef3b..1ad8c780ba7a4 100644 --- a/pandas/_libs/src/datetime/np_datetime.c +++ b/pandas/_libs/src/datetime/np_datetime.c @@ -28,9 +28,9 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt #define PyInt_AsLong PyLong_AsLong #endif -const pandas_datetimestruct _NS_MIN_DTS = { +const npy_datetimestruct _NS_MIN_DTS = { 1677, 9, 21, 0, 12, 43, 145225, 0, 0}; -const pandas_datetimestruct _NS_MAX_DTS = { +const npy_datetimestruct _NS_MAX_DTS = { 2262, 4, 11, 23, 47, 16, 854775, 807000, 0}; @@ -62,7 +62,7 @@ int dayofweek(int y, int m, int d) { * Adjusts a datetimestruct based on a minutes offset. Assumes * the current values are valid.g */ -void add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes) { +void add_minutes_to_datetimestruct(npy_datetimestruct *dts, int minutes) { int isleap; /* MINUTES */ @@ -111,7 +111,7 @@ void add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes) { /* * Calculates the days offset from the 1970 epoch. */ -npy_int64 get_datetimestruct_days(const pandas_datetimestruct *dts) { +npy_int64 get_datetimestruct_days(const npy_datetimestruct *dts) { int i, month; npy_int64 year, days = 0; const int *month_lengths; @@ -211,7 +211,7 @@ static npy_int64 days_to_yearsdays(npy_int64 *days_) { * Adjusts a datetimestruct based on a seconds offset. Assumes * the current values are valid. */ -NPY_NO_EXPORT void add_seconds_to_datetimestruct(pandas_datetimestruct *dts, +NPY_NO_EXPORT void add_seconds_to_datetimestruct(npy_datetimestruct *dts, int seconds) { int minutes; @@ -236,7 +236,7 @@ NPY_NO_EXPORT void add_seconds_to_datetimestruct(pandas_datetimestruct *dts, * offset from 1970. */ static void set_datetimestruct_days(npy_int64 days, - pandas_datetimestruct *dts) { + npy_datetimestruct *dts) { const int *month_lengths; int i; @@ -255,10 +255,10 @@ static void set_datetimestruct_days(npy_int64 days, } /* - * Compares two pandas_datetimestruct objects chronologically + * Compares two npy_datetimestruct objects chronologically */ -int cmp_pandas_datetimestruct(const pandas_datetimestruct *a, - const pandas_datetimestruct *b) { +int cmp_npy_datetimestruct(const npy_datetimestruct *a, + const npy_datetimestruct *b) { if (a->year > b->year) { return 1; } else if (a->year < b->year) { @@ -319,7 +319,7 @@ int cmp_pandas_datetimestruct(const pandas_datetimestruct *a, /* * * Tests for and converts a Python datetime.datetime or datetime.date - * object into a NumPy pandas_datetimestruct. Uses tzinfo (if present) + * object into a NumPy npy_datetimestruct. Uses tzinfo (if present) * to convert to UTC time. * * While the C API has PyDate_* and PyDateTime_* functions, the following @@ -331,12 +331,12 @@ int cmp_pandas_datetimestruct(const pandas_datetimestruct *a, * if obj doesn't have the needed date or datetime attributes. */ int convert_pydatetime_to_datetimestruct(PyObject *obj, - pandas_datetimestruct *out) { + npy_datetimestruct *out) { PyObject *tmp; int isleap; /* Initialize the output to all zeros */ - memset(out, 0, sizeof(pandas_datetimestruct)); + memset(out, 0, sizeof(npy_datetimestruct)); out->month = 1; out->day = 1; @@ -512,8 +512,8 @@ int convert_pydatetime_to_datetimestruct(PyObject *obj, return -1; } -npy_datetime pandas_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, - pandas_datetimestruct *d) { +npy_datetime npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, + npy_datetimestruct *d) { npy_datetime result = NPY_DATETIME_NAT; convert_datetimestruct_to_datetime(fr, d, &result); @@ -521,7 +521,7 @@ npy_datetime pandas_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, } void pandas_datetime_to_datetimestruct(npy_datetime val, NPY_DATETIMEUNIT fr, - pandas_datetimestruct *result) { + npy_datetimestruct *result) { convert_datetime_to_datetimestruct(fr, val, result); } @@ -539,7 +539,7 @@ void pandas_timedelta_to_timedeltastruct(npy_timedelta val, * Returns 0 on success, -1 on failure. */ int convert_datetimestruct_to_datetime(NPY_DATETIMEUNIT base, - const pandas_datetimestruct *dts, + const npy_datetimestruct *dts, npy_datetime *out) { npy_datetime ret; @@ -643,11 +643,11 @@ int convert_datetimestruct_to_datetime(NPY_DATETIMEUNIT base, */ int convert_datetime_to_datetimestruct(NPY_DATETIMEUNIT base, npy_datetime dt, - pandas_datetimestruct *out) { + npy_datetimestruct *out) { npy_int64 perday; /* Initialize the output to all zeros */ - memset(out, 0, sizeof(pandas_datetimestruct)); + memset(out, 0, sizeof(npy_datetimestruct)); out->year = 1970; out->month = 1; out->day = 1; diff --git a/pandas/_libs/src/datetime/np_datetime.h b/pandas/_libs/src/datetime/np_datetime.h index 5644ac036f198..f5c48036c16f8 100644 --- a/pandas/_libs/src/datetime/np_datetime.h +++ b/pandas/_libs/src/datetime/np_datetime.h @@ -19,30 +19,25 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt #include -typedef struct { - npy_int64 year; - npy_int32 month, day, hour, min, sec, us, ps, as; -} pandas_datetimestruct; - typedef struct { npy_int64 days; npy_int32 hrs, min, sec, ms, us, ns, seconds, microseconds, nanoseconds; } pandas_timedeltastruct; -extern const pandas_datetimestruct _NS_MIN_DTS; -extern const pandas_datetimestruct _NS_MAX_DTS; +extern const npy_datetimestruct _NS_MIN_DTS; +extern const npy_datetimestruct _NS_MAX_DTS; // stuff pandas needs // ---------------------------------------------------------------------------- int convert_pydatetime_to_datetimestruct(PyObject *obj, - pandas_datetimestruct *out); + npy_datetimestruct *out); -npy_datetime pandas_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, - pandas_datetimestruct *d); +npy_datetime npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, + npy_datetimestruct *d); void pandas_datetime_to_datetimestruct(npy_datetime val, NPY_DATETIMEUNIT fr, - pandas_datetimestruct *result); + npy_datetimestruct *result); void pandas_timedelta_to_timedeltastruct(npy_timedelta val, NPY_DATETIMEUNIT fr, @@ -61,14 +56,14 @@ int is_leapyear(npy_int64 year); * Calculates the days offset from the 1970 epoch. */ npy_int64 -get_datetimestruct_days(const pandas_datetimestruct *dts); +get_datetimestruct_days(const npy_datetimestruct *dts); /* - * Compares two pandas_datetimestruct objects chronologically + * Compares two npy_datetimestruct objects chronologically */ -int cmp_pandas_datetimestruct(const pandas_datetimestruct *a, - const pandas_datetimestruct *b); +int cmp_npy_datetimestruct(const npy_datetimestruct *a, + const npy_datetimestruct *b); /* @@ -76,12 +71,12 @@ int cmp_pandas_datetimestruct(const pandas_datetimestruct *a, * the current values are valid. */ void -add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes); +add_minutes_to_datetimestruct(npy_datetimestruct *dts, int minutes); int convert_datetime_to_datetimestruct(NPY_DATETIMEUNIT base, npy_datetime dt, - pandas_datetimestruct *out); + npy_datetimestruct *out); #endif // PANDAS__LIBS_SRC_DATETIME_NP_DATETIME_H_ diff --git a/pandas/_libs/src/datetime/np_datetime_strings.c b/pandas/_libs/src/datetime/np_datetime_strings.c index b1852094c301e..fa96cce1756c8 100644 --- a/pandas/_libs/src/datetime/np_datetime_strings.c +++ b/pandas/_libs/src/datetime/np_datetime_strings.c @@ -63,7 +63,7 @@ This file implements string parsing and creation for NumPy datetime. * Returns 0 on success, -1 on failure. */ int parse_iso_8601_datetime(char *str, int len, - pandas_datetimestruct *out, + npy_datetimestruct *out, int *out_local, int *out_tzoffset) { int year_leap = 0; int i, numdigits; @@ -86,7 +86,7 @@ int parse_iso_8601_datetime(char *str, int len, int hour_was_2_digits = 0; /* Initialize the output to all zeros */ - memset(out, 0, sizeof(pandas_datetimestruct)); + memset(out, 0, sizeof(npy_datetimestruct)); out->month = 1; out->day = 1; @@ -567,7 +567,7 @@ int get_datetime_iso_8601_strlen(int local, NPY_DATETIMEUNIT base) { /* - * Converts an pandas_datetimestruct to an (almost) ISO 8601 + * Converts an npy_datetimestruct to an (almost) ISO 8601 * NULL-terminated string using timezone Z (UTC). If the string fits in * the space exactly, it leaves out the NULL terminator and returns success. * @@ -580,7 +580,7 @@ int get_datetime_iso_8601_strlen(int local, NPY_DATETIMEUNIT base) { * Returns 0 on success, -1 on failure (for example if the output * string was too short). */ -int make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen, +int make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, int outlen, NPY_DATETIMEUNIT base) { char *substr = outstr, sublen = outlen; int tmplen; diff --git a/pandas/_libs/src/datetime/np_datetime_strings.h b/pandas/_libs/src/datetime/np_datetime_strings.h index ff1d26e5168b5..821bb79b345bd 100644 --- a/pandas/_libs/src/datetime/np_datetime_strings.h +++ b/pandas/_libs/src/datetime/np_datetime_strings.h @@ -51,9 +51,9 @@ This file implements string parsing and creation for NumPy datetime. */ int parse_iso_8601_datetime(char *str, int len, - pandas_datetimestruct *out, - int *out_local, - int *out_tzoffset); + npy_datetimestruct *out, + int *out_local, + int *out_tzoffset); /* * Provides a string length to use for converting datetime @@ -63,7 +63,7 @@ int get_datetime_iso_8601_strlen(int local, NPY_DATETIMEUNIT base); /* - * Converts an pandas_datetimestruct to an (almost) ISO 8601 + * Converts an npy_datetimestruct to an (almost) ISO 8601 * NULL-terminated string using timezone Z (UTC). * * 'base' restricts the output to that unit. Set 'base' to @@ -73,7 +73,7 @@ get_datetime_iso_8601_strlen(int local, NPY_DATETIMEUNIT base); * string was too short). */ int -make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen, +make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, int outlen, NPY_DATETIMEUNIT base); #endif // PANDAS__LIBS_SRC_DATETIME_NP_DATETIME_STRINGS_H_ diff --git a/pandas/_libs/src/period_helper.c b/pandas/_libs/src/period_helper.c index 5011d33d189c2..7dab77131c1a0 100644 --- a/pandas/_libs/src/period_helper.c +++ b/pandas/_libs/src/period_helper.c @@ -47,14 +47,14 @@ static int monthToQuarter(int month) { return ((month - 1) / 3) + 1; } * Assumes GREGORIAN_CALENDAR */ npy_int64 unix_date_from_ymd(int year, int month, int day) { /* Calculate the absolute date */ - pandas_datetimestruct dts; + npy_datetimestruct dts; npy_int64 unix_date; - memset(&dts, 0, sizeof(pandas_datetimestruct)); + memset(&dts, 0, sizeof(npy_datetimestruct)); dts.year = year; dts.month = month; dts.day = day; - unix_date = pandas_datetimestruct_to_datetime(NPY_FR_D, &dts); + unix_date = npy_datetimestruct_to_datetime(NPY_FR_D, &dts); return unix_date; } @@ -127,7 +127,7 @@ static npy_int64 DtoB_weekday(npy_int64 unix_date) { return floordiv(unix_date + 4, 7) * 5 + mod_compat(unix_date + 4, 7) - 4; } -static npy_int64 DtoB(pandas_datetimestruct *dts, +static npy_int64 DtoB(npy_datetimestruct *dts, int roll_back, npy_int64 unix_date) { int day_of_week = dayofweek(dts->year, dts->month, dts->day); @@ -149,7 +149,7 @@ static npy_int64 DtoB(pandas_datetimestruct *dts, //************ FROM DAILY *************** static npy_int64 asfreq_DTtoA(npy_int64 ordinal, asfreq_info *af_info) { - pandas_datetimestruct dts; + npy_datetimestruct dts; ordinal = downsample_daytime(ordinal, af_info); pandas_datetime_to_datetimestruct(ordinal, NPY_FR_D, &dts); if (dts.month > af_info->to_end) { @@ -160,7 +160,7 @@ static npy_int64 asfreq_DTtoA(npy_int64 ordinal, asfreq_info *af_info) { } static int DtoQ_yq(npy_int64 ordinal, asfreq_info *af_info, int *year) { - pandas_datetimestruct dts; + npy_datetimestruct dts; int quarter; pandas_datetime_to_datetimestruct(ordinal, NPY_FR_D, &dts); @@ -188,7 +188,7 @@ static npy_int64 asfreq_DTtoQ(npy_int64 ordinal, asfreq_info *af_info) { } static npy_int64 asfreq_DTtoM(npy_int64 ordinal, asfreq_info *af_info) { - pandas_datetimestruct dts; + npy_datetimestruct dts; ordinal = downsample_daytime(ordinal, af_info); @@ -203,7 +203,7 @@ static npy_int64 asfreq_DTtoW(npy_int64 ordinal, asfreq_info *af_info) { static npy_int64 asfreq_DTtoB(npy_int64 ordinal, asfreq_info *af_info) { int roll_back; - pandas_datetimestruct dts; + npy_datetimestruct dts; npy_int64 unix_date = downsample_daytime(ordinal, af_info); pandas_datetime_to_datetimestruct(unix_date, NPY_FR_D, &dts); @@ -262,7 +262,7 @@ static npy_int64 asfreq_WtoW(npy_int64 ordinal, asfreq_info *af_info) { static npy_int64 asfreq_WtoB(npy_int64 ordinal, asfreq_info *af_info) { int roll_back; - pandas_datetimestruct dts; + npy_datetimestruct dts; npy_int64 unix_date = asfreq_WtoDT(ordinal, af_info); pandas_datetime_to_datetimestruct(unix_date, NPY_FR_D, &dts); @@ -302,7 +302,7 @@ static npy_int64 asfreq_MtoW(npy_int64 ordinal, asfreq_info *af_info) { static npy_int64 asfreq_MtoB(npy_int64 ordinal, asfreq_info *af_info) { int roll_back; - pandas_datetimestruct dts; + npy_datetimestruct dts; npy_int64 unix_date = asfreq_MtoDT(ordinal, af_info); pandas_datetime_to_datetimestruct(unix_date, NPY_FR_D, &dts); @@ -357,7 +357,7 @@ static npy_int64 asfreq_QtoW(npy_int64 ordinal, asfreq_info *af_info) { static npy_int64 asfreq_QtoB(npy_int64 ordinal, asfreq_info *af_info) { int roll_back; - pandas_datetimestruct dts; + npy_datetimestruct dts; npy_int64 unix_date = asfreq_QtoDT(ordinal, af_info); pandas_datetime_to_datetimestruct(unix_date, NPY_FR_D, &dts); @@ -414,7 +414,7 @@ static npy_int64 asfreq_AtoW(npy_int64 ordinal, asfreq_info *af_info) { static npy_int64 asfreq_AtoB(npy_int64 ordinal, asfreq_info *af_info) { int roll_back; - pandas_datetimestruct dts; + npy_datetimestruct dts; npy_int64 unix_date = asfreq_AtoDT(ordinal, af_info); pandas_datetime_to_datetimestruct(unix_date, NPY_FR_D, &dts); diff --git a/pandas/_libs/src/ujson/python/objToJSON.c b/pandas/_libs/src/ujson/python/objToJSON.c index eaa4eca44c15b..c9b0143ffc6ca 100644 --- a/pandas/_libs/src/ujson/python/objToJSON.c +++ b/pandas/_libs/src/ujson/python/objToJSON.c @@ -442,7 +442,7 @@ static void *PyUnicodeToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue, return PyString_AS_STRING(newObj); } -static void *PandasDateTimeStructToJSON(pandas_datetimestruct *dts, +static void *PandasDateTimeStructToJSON(npy_datetimestruct *dts, JSONTypeContext *tc, void *outValue, size_t *_outLen) { NPY_DATETIMEUNIT base = ((PyObjectEncoder *)tc->encoder)->datetimeUnit; @@ -471,14 +471,14 @@ static void *PandasDateTimeStructToJSON(pandas_datetimestruct *dts, } } else { PRINTMARK(); - *((JSINT64 *)outValue) = pandas_datetimestruct_to_datetime(base, dts); + *((JSINT64 *)outValue) = npy_datetimestruct_to_datetime(base, dts); return NULL; } } static void *NpyDateTimeScalarToJSON(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen) { - pandas_datetimestruct dts; + npy_datetimestruct dts; PyDatetimeScalarObject *obj = (PyDatetimeScalarObject *)_obj; PRINTMARK(); @@ -489,7 +489,7 @@ static void *NpyDateTimeScalarToJSON(JSOBJ _obj, JSONTypeContext *tc, static void *PyDateTimeToJSON(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen) { - pandas_datetimestruct dts; + npy_datetimestruct dts; PyObject *obj = (PyObject *)_obj; PRINTMARK(); @@ -509,7 +509,7 @@ static void *PyDateTimeToJSON(JSOBJ _obj, JSONTypeContext *tc, void *outValue, static void *NpyDatetime64ToJSON(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen) { - pandas_datetimestruct dts; + npy_datetimestruct dts; PRINTMARK(); pandas_datetime_to_datetimestruct((npy_datetime)GET_TC(tc)->longValue, diff --git a/pandas/_libs/tslib.pyx b/pandas/_libs/tslib.pyx index 281e497945c5f..f8ce346b16317 100644 --- a/pandas/_libs/tslib.pyx +++ b/pandas/_libs/tslib.pyx @@ -21,7 +21,7 @@ PyDateTime_IMPORT from tslibs.np_datetime cimport (check_dts_bounds, - pandas_datetimestruct, + npy_datetimestruct, _string_to_dts, dt64_to_dtstruct, dtstruct_to_dt64, pydatetime_to_dt64, pydate_to_dt64, @@ -58,20 +58,20 @@ cdef bint PY2 = str == bytes cdef inline object create_datetime_from_ts( - int64_t value, pandas_datetimestruct dts, + int64_t value, npy_datetimestruct dts, object tz, object freq): """ convenience routine to construct a datetime.datetime from its parts """ return datetime(dts.year, dts.month, dts.day, dts.hour, dts.min, dts.sec, dts.us, tz) cdef inline object create_date_from_ts( - int64_t value, pandas_datetimestruct dts, + int64_t value, npy_datetimestruct dts, object tz, object freq): """ convenience routine to construct a datetime.date from its parts """ return date(dts.year, dts.month, dts.day) cdef inline object create_time_from_ts( - int64_t value, pandas_datetimestruct dts, + int64_t value, npy_datetimestruct dts, object tz, object freq): """ convenience routine to construct a datetime.time from its parts """ return time(dts.hour, dts.min, dts.sec, dts.us) @@ -103,11 +103,11 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, freq=None, cdef: Py_ssize_t i, n = len(arr) ndarray[int64_t] trans, deltas - pandas_datetimestruct dts + npy_datetimestruct dts object dt int64_t value ndarray[object] result = np.empty(n, dtype=object) - object (*func_create)(int64_t, pandas_datetimestruct, object, object) + object (*func_create)(int64_t, npy_datetimestruct, object, object) if box == "date": assert (tz is None), "tz should be None when converting to date" @@ -230,7 +230,7 @@ def format_array_from_datetime(ndarray[int64_t] values, object tz=None, bint show_ms = 0, show_us = 0, show_ns = 0, basic_format = 0 ndarray[object] result = np.empty(N, dtype=object) object ts, res - pandas_datetimestruct dts + npy_datetimestruct dts if na_rep is None: na_rep = 'NaT' @@ -454,7 +454,7 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise', object val, py_dt ndarray[int64_t] iresult ndarray[object] oresult - pandas_datetimestruct dts + npy_datetimestruct dts bint utc_convert = bool(utc) bint seen_integer = 0 bint seen_string = 0 diff --git a/pandas/_libs/tslibs/conversion.pxd b/pandas/_libs/tslibs/conversion.pxd index 448dbd27e8278..96e4676fe91c0 100644 --- a/pandas/_libs/tslibs/conversion.pxd +++ b/pandas/_libs/tslibs/conversion.pxd @@ -5,12 +5,12 @@ from cpython.datetime cimport datetime, tzinfo from numpy cimport int64_t, int32_t -from np_datetime cimport pandas_datetimestruct +from np_datetime cimport npy_datetimestruct cdef class _TSObject: cdef: - pandas_datetimestruct dts # pandas_datetimestruct + npy_datetimestruct dts # npy_datetimestruct int64_t value # numpy dt64 object tzinfo diff --git a/pandas/_libs/tslibs/conversion.pyx b/pandas/_libs/tslibs/conversion.pyx index b948be606645d..d0090852fa5af 100644 --- a/pandas/_libs/tslibs/conversion.pyx +++ b/pandas/_libs/tslibs/conversion.pyx @@ -19,7 +19,7 @@ from cpython.datetime cimport (datetime, tzinfo, PyDateTime_IMPORT from np_datetime cimport (check_dts_bounds, - pandas_datetimestruct, + npy_datetimestruct, pandas_datetime_to_datetimestruct, _string_to_dts, npy_datetime, dt64_to_dtstruct, dtstruct_to_dt64, @@ -60,7 +60,7 @@ cdef inline int64_t get_datetime64_nanos(object val) except? -1: value to nanoseconds if necessary. """ cdef: - pandas_datetimestruct dts + npy_datetimestruct dts NPY_DATETIMEUNIT unit npy_datetime ival @@ -93,7 +93,7 @@ def ensure_datetime64ns(ndarray arr, copy=True): Py_ssize_t i, n = arr.size ndarray[int64_t] ivalues, iresult NPY_DATETIMEUNIT unit - pandas_datetimestruct dts + npy_datetimestruct dts shape = ( arr).shape @@ -157,7 +157,7 @@ def datetime_to_datetime64(ndarray[object] values): Py_ssize_t i, n = len(values) object val, inferred_tz = None ndarray[int64_t] iresult - pandas_datetimestruct dts + npy_datetimestruct dts _TSObject _ts result = np.empty(n, dtype='M8[ns]') @@ -203,7 +203,7 @@ cdef inline maybe_datetimelike_to_i8(object val): val : int64 timestamp or original input """ cdef: - pandas_datetimestruct dts + npy_datetimestruct dts try: return val.value except AttributeError: @@ -220,7 +220,7 @@ cdef inline maybe_datetimelike_to_i8(object val): # lightweight C object to hold datetime & int64 pair cdef class _TSObject: # cdef: - # pandas_datetimestruct dts # pandas_datetimestruct + # npy_datetimestruct dts # npy_datetimestruct # int64_t value # numpy dt64 # object tzinfo @@ -682,7 +682,7 @@ cdef inline int64_t _tz_convert_tzlocal_utc(int64_t val, tzinfo tz, result : int64_t """ cdef: - pandas_datetimestruct dts + npy_datetimestruct dts int64_t result, delta datetime dt @@ -730,7 +730,7 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2): ndarray[int64_t] trans, deltas Py_ssize_t pos int64_t v, offset, utc_date - pandas_datetimestruct dts + npy_datetimestruct dts ndarray[int64_t] arr # TODO: Is there a lighter-weight way to do this? # See GH#17734 We should always be converting either from UTC or to UTC @@ -784,7 +784,7 @@ def tz_convert(ndarray[int64_t] vals, object tz1, object tz2): Py_ssize_t i, j, pos, n = len(vals) ndarray[Py_ssize_t] posn int64_t v, offset, delta - pandas_datetimestruct dts + npy_datetimestruct dts if len(vals) == 0: return np.array([], dtype=np.int64) @@ -849,7 +849,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None, int64_t *tdata int64_t v, left, right ndarray[int64_t] result, result_a, result_b, dst_hours - pandas_datetimestruct dts + npy_datetimestruct dts bint infer_dst = False, is_dst = False, fill = False bint is_coerce = errors == 'coerce', is_raise = errors == 'raise' @@ -1086,7 +1086,7 @@ def normalize_i8_timestamps(ndarray[int64_t] stamps, tz=None): """ cdef: Py_ssize_t i, n = len(stamps) - pandas_datetimestruct dts + npy_datetimestruct dts ndarray[int64_t] result = np.empty(n, dtype=np.int64) if tz is not None: @@ -1125,7 +1125,7 @@ cdef ndarray[int64_t] _normalize_local(ndarray[int64_t] stamps, object tz): Py_ssize_t n = len(stamps) ndarray[int64_t] result = np.empty(n, dtype=np.int64) ndarray[int64_t] trans, deltas, pos - pandas_datetimestruct dts + npy_datetimestruct dts if is_utc(tz): with nogil: @@ -1168,13 +1168,13 @@ cdef ndarray[int64_t] _normalize_local(ndarray[int64_t] stamps, object tz): return result -cdef inline int64_t _normalized_stamp(pandas_datetimestruct *dts) nogil: +cdef inline int64_t _normalized_stamp(npy_datetimestruct *dts) nogil: """ Normalize the given datetimestruct to midnight, then convert to int64_t. Parameters ---------- - *dts : pointer to pandas_datetimestruct + *dts : pointer to npy_datetimestruct Returns ------- @@ -1206,7 +1206,7 @@ def is_date_array_normalized(ndarray[int64_t] stamps, tz=None): cdef: Py_ssize_t i, n = len(stamps) ndarray[int64_t] trans, deltas - pandas_datetimestruct dts + npy_datetimestruct dts int64_t local_val if tz is None or is_utc(tz): diff --git a/pandas/_libs/tslibs/fields.pyx b/pandas/_libs/tslibs/fields.pyx index ccf67e765e079..a298f521ef853 100644 --- a/pandas/_libs/tslibs/fields.pyx +++ b/pandas/_libs/tslibs/fields.pyx @@ -16,7 +16,7 @@ cnp.import_array() from ccalendar import get_locale_names, MONTHS_FULL, DAYS_FULL from ccalendar cimport (get_days_in_month, is_leapyear, dayofweek, get_week_of_year, get_day_of_year) -from np_datetime cimport (pandas_datetimestruct, pandas_timedeltastruct, +from np_datetime cimport (npy_datetimestruct, pandas_timedeltastruct, dt64_to_dtstruct, td64_to_tdstruct) from nattype cimport NPY_NAT @@ -47,7 +47,7 @@ def build_field_sarray(ndarray[int64_t] dtindex): """ cdef: Py_ssize_t i, count = 0 - pandas_datetimestruct dts + npy_datetimestruct dts ndarray[int32_t] years, months, days, hours, minutes, seconds, mus count = len(dtindex) @@ -94,7 +94,7 @@ def get_date_name_field(ndarray[int64_t] dtindex, object field, cdef: Py_ssize_t i, count = 0 ndarray[object] out, names - pandas_datetimestruct dts + npy_datetimestruct dts int dow count = len(dtindex) @@ -150,7 +150,7 @@ def get_start_end_field(ndarray[int64_t] dtindex, object field, ndarray[int8_t] out ndarray[int32_t, ndim=2] _month_offset bint isleap - pandas_datetimestruct dts + npy_datetimestruct dts int mo_off, dom, doy, dow, ldom _month_offset = np.array( @@ -389,7 +389,7 @@ def get_date_field(ndarray[int64_t] dtindex, object field): cdef: Py_ssize_t i, count = 0 ndarray[int32_t] out - pandas_datetimestruct dts + npy_datetimestruct dts count = len(dtindex) out = np.empty(count, dtype='i4') diff --git a/pandas/_libs/tslibs/np_datetime.pxd b/pandas/_libs/tslibs/np_datetime.pxd index 7c91c5551dc47..a585259286a58 100644 --- a/pandas/_libs/tslibs/np_datetime.pxd +++ b/pandas/_libs/tslibs/np_datetime.pxd @@ -25,15 +25,11 @@ cdef extern from "numpy/arrayscalars.h": npy_timedelta obval PyArray_DatetimeMetaData obmeta -cdef extern from "../src/datetime/np_datetime.h": - ctypedef struct pandas_datetimestruct: +cdef extern from "numpy/ndarraytypes.h": + ctypedef struct npy_datetimestruct: int64_t year int32_t month, day, hour, min, sec, us, ps, as - ctypedef struct pandas_timedeltastruct: - int64_t days - int32_t hrs, min, sec, ms, us, ns, seconds, microseconds, nanoseconds - ctypedef enum NPY_DATETIMEUNIT: NPY_FR_Y NPY_FR_M @@ -50,27 +46,32 @@ cdef extern from "../src/datetime/np_datetime.h": NPY_FR_fs NPY_FR_as +cdef extern from "../src/datetime/np_datetime.h": + ctypedef struct pandas_timedeltastruct: + int64_t days + int32_t hrs, min, sec, ms, us, ns, seconds, microseconds, nanoseconds + void pandas_datetime_to_datetimestruct(npy_datetime val, NPY_DATETIMEUNIT fr, - pandas_datetimestruct *result) nogil + npy_datetimestruct *result) nogil cdef int reverse_ops[6] cdef bint cmp_scalar(int64_t lhs, int64_t rhs, int op) except -1 -cdef check_dts_bounds(pandas_datetimestruct *dts) +cdef check_dts_bounds(npy_datetimestruct *dts) -cdef int64_t dtstruct_to_dt64(pandas_datetimestruct* dts) nogil -cdef void dt64_to_dtstruct(int64_t dt64, pandas_datetimestruct* out) nogil +cdef int64_t dtstruct_to_dt64(npy_datetimestruct* dts) nogil +cdef void dt64_to_dtstruct(int64_t dt64, npy_datetimestruct* out) nogil cdef void td64_to_tdstruct(int64_t td64, pandas_timedeltastruct* out) nogil -cdef int64_t pydatetime_to_dt64(datetime val, pandas_datetimestruct *dts) -cdef int64_t pydate_to_dt64(date val, pandas_datetimestruct *dts) +cdef int64_t pydatetime_to_dt64(datetime val, npy_datetimestruct *dts) +cdef int64_t pydate_to_dt64(date val, npy_datetimestruct *dts) cdef npy_datetime get_datetime64_value(object obj) nogil cdef npy_timedelta get_timedelta64_value(object obj) nogil cdef NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil -cdef int _string_to_dts(object val, pandas_datetimestruct* dts, +cdef int _string_to_dts(object val, npy_datetimestruct* dts, int* out_local, int* out_tzoffset) except? -1 diff --git a/pandas/_libs/tslibs/np_datetime.pyx b/pandas/_libs/tslibs/np_datetime.pyx index e58ec0702adcc..3c0fe98ee7b7d 100644 --- a/pandas/_libs/tslibs/np_datetime.pyx +++ b/pandas/_libs/tslibs/np_datetime.pyx @@ -16,27 +16,26 @@ PyDateTime_IMPORT from numpy cimport int64_t cdef extern from "../src/datetime/np_datetime.h": - int cmp_pandas_datetimestruct(pandas_datetimestruct *a, - pandas_datetimestruct *b) + int cmp_npy_datetimestruct(npy_datetimestruct *a, + npy_datetimestruct *b) - npy_datetime pandas_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, - pandas_datetimestruct *d - ) nogil + npy_datetime npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, + npy_datetimestruct *d) nogil void pandas_datetime_to_datetimestruct(npy_datetime val, NPY_DATETIMEUNIT fr, - pandas_datetimestruct *result) nogil + npy_datetimestruct *result) nogil void pandas_timedelta_to_timedeltastruct(npy_timedelta val, NPY_DATETIMEUNIT fr, pandas_timedeltastruct *result ) nogil - pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS + npy_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS cdef extern from "../src/datetime/np_datetime_strings.h": int parse_iso_8601_datetime(char *str, int len, - pandas_datetimestruct *out, + npy_datetimestruct *out, int *out_local, int *out_tzoffset) # ---------------------------------------------------------------------- @@ -101,17 +100,17 @@ class OutOfBoundsDatetime(ValueError): pass -cdef inline check_dts_bounds(pandas_datetimestruct *dts): +cdef inline check_dts_bounds(npy_datetimestruct *dts): """Raises OutOfBoundsDatetime if the given date is outside the range that can be represented by nanosecond-resolution 64-bit integers.""" cdef: bint error = False if (dts.year <= 1677 and - cmp_pandas_datetimestruct(dts, &_NS_MIN_DTS) == -1): + cmp_npy_datetimestruct(dts, &_NS_MIN_DTS) == -1): error = True elif (dts.year >= 2262 and - cmp_pandas_datetimestruct(dts, &_NS_MAX_DTS) == 1): + cmp_npy_datetimestruct(dts, &_NS_MAX_DTS) == 1): error = True if error: @@ -125,14 +124,14 @@ cdef inline check_dts_bounds(pandas_datetimestruct *dts): # ---------------------------------------------------------------------- # Conversion -cdef inline int64_t dtstruct_to_dt64(pandas_datetimestruct* dts) nogil: - """Convenience function to call pandas_datetimestruct_to_datetime +cdef inline int64_t dtstruct_to_dt64(npy_datetimestruct* dts) nogil: + """Convenience function to call npy_datetimestruct_to_datetime with the by-far-most-common frequency NPY_FR_ns""" - return pandas_datetimestruct_to_datetime(NPY_FR_ns, dts) + return npy_datetimestruct_to_datetime(NPY_FR_ns, dts) cdef inline void dt64_to_dtstruct(int64_t dt64, - pandas_datetimestruct* out) nogil: + npy_datetimestruct* out) nogil: """Convenience function to call pandas_datetime_to_datetimestruct with the by-far-most-common frequency NPY_FR_ns""" pandas_datetime_to_datetimestruct(dt64, NPY_FR_ns, out) @@ -147,7 +146,7 @@ cdef inline void td64_to_tdstruct(int64_t td64, cdef inline int64_t pydatetime_to_dt64(datetime val, - pandas_datetimestruct *dts): + npy_datetimestruct *dts): dts.year = PyDateTime_GET_YEAR(val) dts.month = PyDateTime_GET_MONTH(val) dts.day = PyDateTime_GET_DAY(val) @@ -160,7 +159,7 @@ cdef inline int64_t pydatetime_to_dt64(datetime val, cdef inline int64_t pydate_to_dt64(date val, - pandas_datetimestruct *dts): + npy_datetimestruct *dts): dts.year = PyDateTime_GET_YEAR(val) dts.month = PyDateTime_GET_MONTH(val) dts.day = PyDateTime_GET_DAY(val) @@ -169,7 +168,7 @@ cdef inline int64_t pydate_to_dt64(date val, return dtstruct_to_dt64(dts) -cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts, +cdef inline int _string_to_dts(object val, npy_datetimestruct* dts, int* out_local, int* out_tzoffset) except? -1: cdef: int result @@ -187,7 +186,7 @@ cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts, cdef inline int _cstring_to_dts(char *val, int length, - pandas_datetimestruct* dts, + npy_datetimestruct* dts, int* out_local, int* out_tzoffset) except? -1: # Note: without this "extra layer" between _string_to_dts # and parse_iso_8601_datetime, calling _string_to_dts raises diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 27b7f03358a3a..1efcfaa5b9741 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -24,7 +24,7 @@ from ccalendar import MONTHS, DAYS from ccalendar cimport get_days_in_month, dayofweek from conversion cimport tz_convert_single, pydt_to_i8, localize_pydatetime from nattype cimport NPY_NAT -from np_datetime cimport (pandas_datetimestruct, +from np_datetime cimport (npy_datetimestruct, dtstruct_to_dt64, dt64_to_dtstruct) # --------------------------------------------------------------------- @@ -548,14 +548,14 @@ cpdef datetime shift_day(datetime other, int days): return localize_pydatetime(shifted, tz) -cdef inline int year_add_months(pandas_datetimestruct dts, int months) nogil: - """new year number after shifting pandas_datetimestruct number of months""" +cdef inline int year_add_months(npy_datetimestruct dts, int months) nogil: + """new year number after shifting npy_datetimestruct number of months""" return dts.year + (dts.month + months - 1) / 12 -cdef inline int month_add_months(pandas_datetimestruct dts, int months) nogil: +cdef inline int month_add_months(npy_datetimestruct dts, int months) nogil: """ - New month number after shifting pandas_datetimestruct + New month number after shifting npy_datetimestruct number of months. """ cdef int new_month = (dts.month + months) % 12 @@ -584,7 +584,7 @@ def shift_quarters(int64_t[:] dtindex, int quarters, """ cdef: Py_ssize_t i - pandas_datetimestruct dts + npy_datetimestruct dts int count = len(dtindex) int months_to_roll, months_since, n, compare_day bint roll_check @@ -726,7 +726,7 @@ def shift_months(int64_t[:] dtindex, int months, object day=None): """ cdef: Py_ssize_t i - pandas_datetimestruct dts + npy_datetimestruct dts int count = len(dtindex) int months_to_roll bint roll_check diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 0ec5d25beeeb9..3d38320e31533 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -22,15 +22,14 @@ from cpython.datetime cimport (PyDateTime_Check, PyDelta_Check, # import datetime C API PyDateTime_IMPORT -from np_datetime cimport (pandas_datetimestruct, dtstruct_to_dt64, +from np_datetime cimport (npy_datetimestruct, dtstruct_to_dt64, dt64_to_dtstruct, pandas_datetime_to_datetimestruct, NPY_DATETIMEUNIT, NPY_FR_D) cdef extern from "../src/datetime/np_datetime.h": - int64_t pandas_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, - pandas_datetimestruct *d - ) nogil + int64_t npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr, + npy_datetimestruct *d) nogil cimport util from util cimport is_period_object, is_string_object, INT32_MIN @@ -87,14 +86,14 @@ cdef extern from "period_helper.h": @cython.cdivision -cdef char* c_strftime(pandas_datetimestruct *dts, char *fmt): +cdef char* c_strftime(npy_datetimestruct *dts, char *fmt): """ Generate a nice string representation of the period object, originally from DateObject_strftime Parameters ---------- - dts : pandas_datetimestruct* + dts : npy_datetimestruct* fmt : char* Returns @@ -124,7 +123,7 @@ cdef char* c_strftime(pandas_datetimestruct *dts, char *fmt): # ---------------------------------------------------------------------- -# Conversion between date_info and pandas_datetimestruct +# Conversion between date_info and npy_datetimestruct cdef inline int get_freq_group(int freq) nogil: return (freq // 1000) * 1000 @@ -137,13 +136,13 @@ cdef inline int get_freq_group_index(int freq) nogil: # specifically _dont_ use cdvision or else ordinals near -1 are assigned to # incorrect dates GH#19643 @cython.cdivision(False) -cdef int64_t get_period_ordinal(pandas_datetimestruct *dts, int freq) nogil: +cdef int64_t get_period_ordinal(npy_datetimestruct *dts, int freq) nogil: """ Generate an ordinal in period space Parameters ---------- - dts: pandas_datetimestruct* + dts: npy_datetimestruct* freq : int Returns @@ -187,7 +186,7 @@ cdef int64_t get_period_ordinal(pandas_datetimestruct *dts, int freq) nogil: elif freq == FR_MTH: return (dts.year - 1970) * 12 + dts.month - 1 - unix_date = pandas_datetimestruct_to_datetime(NPY_FR_D, dts) + unix_date = npy_datetimestruct_to_datetime(NPY_FR_D, dts) if freq >= FR_SEC: seconds = unix_date * 86400 + dts.hour * 3600 + dts.min * 60 + dts.sec @@ -238,7 +237,7 @@ cdef int64_t get_period_ordinal(pandas_datetimestruct *dts, int freq) nogil: cdef void get_date_info(int64_t ordinal, int freq, - pandas_datetimestruct *dts) nogil: + npy_datetimestruct *dts) nogil: cdef: int64_t unix_date double abstime @@ -286,7 +285,7 @@ cdef int64_t get_unix_date(int64_t period_ordinal, int freq) nogil: @cython.cdivision -cdef void date_info_from_days_and_time(pandas_datetimestruct *dts, +cdef void date_info_from_days_and_time(npy_datetimestruct *dts, int64_t unix_date, double abstime) nogil: """ @@ -294,7 +293,7 @@ cdef void date_info_from_days_and_time(pandas_datetimestruct *dts, Parameters ---------- - dts : pandas_datetimestruct* + dts : npy_datetimestruct* unix_date : int64_t days elapsed since datetime(1970, 1, 1) abstime : double @@ -397,7 +396,7 @@ cdef int get_yq(int64_t ordinal, int freq, int *quarter, int *year): cdef int DtoQ_yq(int64_t unix_date, asfreq_info *af_info, int *year): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts int quarter date_info_from_days_and_time(&dts, unix_date, 0) @@ -432,7 +431,7 @@ def dt64arr_to_periodarr(ndarray[int64_t] dtarr, int freq, tz=None): cdef: ndarray[int64_t] out Py_ssize_t i, l - pandas_datetimestruct dts + npy_datetimestruct dts l = len(dtarr) @@ -610,7 +609,7 @@ cpdef int64_t period_ordinal(int y, int m, int d, int h, int min, ordinal : int64_t """ cdef: - pandas_datetimestruct dts + npy_datetimestruct dts dts.year = y dts.month = m dts.day = d @@ -624,7 +623,7 @@ cpdef int64_t period_ordinal(int y, int m, int d, int h, int min, cpdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) nogil: cdef: - pandas_datetimestruct dts + npy_datetimestruct dts if ordinal == NPY_NAT: return NPY_NAT @@ -687,7 +686,7 @@ cdef list str_extra_fmts = ["^`AB`^", "^`CD`^", "^`EF`^", cdef object _period_strftime(int64_t value, int freq, object fmt): cdef: Py_ssize_t i - pandas_datetimestruct dts + npy_datetimestruct dts char *formatted object pat, repl, result list found_pat = [False] * len(extra_fmts) @@ -743,7 +742,7 @@ ctypedef int (*accessor)(int64_t ordinal, int freq) except INT32_MIN cdef int pyear(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return dts.year @@ -765,63 +764,63 @@ cdef int pquarter(int64_t ordinal, int freq): cdef int pmonth(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return dts.month cdef int pday(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return dts.day cdef int pweekday(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return dayofweek(dts.year, dts.month, dts.day) cdef int pday_of_year(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return get_day_of_year(dts.year, dts.month, dts.day) cdef int pweek(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return ccalendar.get_week_of_year(dts.year, dts.month, dts.day) cdef int phour(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return dts.hour cdef int pminute(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return dts.min cdef int psecond(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return dts.sec cdef int pdays_in_month(int64_t ordinal, int freq): cdef: - pandas_datetimestruct dts + npy_datetimestruct dts get_date_info(ordinal, freq, &dts) return ccalendar.get_days_in_month(dts.year, dts.month) @@ -936,7 +935,7 @@ cdef ndarray[int64_t] localize_dt64arr_to_period(ndarray[int64_t] stamps, Py_ssize_t n = len(stamps) ndarray[int64_t] result = np.empty(n, dtype=np.int64) ndarray[int64_t] trans, deltas, pos - pandas_datetimestruct dts + npy_datetimestruct dts int64_t local_val if is_utc(tz): diff --git a/pandas/_libs/tslibs/resolution.pyx b/pandas/_libs/tslibs/resolution.pyx index a53d794b48cfa..10e730763175d 100644 --- a/pandas/_libs/tslibs/resolution.pyx +++ b/pandas/_libs/tslibs/resolution.pyx @@ -15,7 +15,7 @@ from pandas._libs.khash cimport (khiter_t, kh_init_int64, kh_int64_t, kh_resize_int64, kh_get_int64) -from np_datetime cimport pandas_datetimestruct, dt64_to_dtstruct +from np_datetime cimport npy_datetimestruct, dt64_to_dtstruct from frequencies cimport get_freq_code from timezones cimport (is_utc, is_tzlocal, maybe_get_tz, get_dst_info) @@ -53,7 +53,7 @@ _ONE_DAY = (24 * _ONE_HOUR) cpdef resolution(ndarray[int64_t] stamps, tz=None): cdef: Py_ssize_t i, n = len(stamps) - pandas_datetimestruct dts + npy_datetimestruct dts int reso = RESO_DAY, curr_reso if tz is not None: @@ -75,7 +75,7 @@ cdef _reso_local(ndarray[int64_t] stamps, object tz): Py_ssize_t n = len(stamps) int reso = RESO_DAY, curr_reso ndarray[int64_t] trans, deltas, pos - pandas_datetimestruct dts + npy_datetimestruct dts int64_t local_val if is_utc(tz): @@ -122,7 +122,7 @@ cdef _reso_local(ndarray[int64_t] stamps, object tz): return reso -cdef inline int _reso_stamp(pandas_datetimestruct *dts): +cdef inline int _reso_stamp(npy_datetimestruct *dts): if dts.us != 0: if dts.us % 1000 == 0: return RESO_MS diff --git a/pandas/_libs/tslibs/strptime.pyx b/pandas/_libs/tslibs/strptime.pyx index 5b3d4399a6e10..a843a8e2b5612 100644 --- a/pandas/_libs/tslibs/strptime.pyx +++ b/pandas/_libs/tslibs/strptime.pyx @@ -33,7 +33,7 @@ from numpy cimport ndarray, int64_t from datetime import date as datetime_date from np_datetime cimport (check_dts_bounds, - dtstruct_to_dt64, pandas_datetimestruct) + dtstruct_to_dt64, npy_datetimestruct) from util cimport is_string_object @@ -77,7 +77,7 @@ def array_strptime(ndarray[object] values, object fmt, cdef: Py_ssize_t i, n = len(values) - pandas_datetimestruct dts + npy_datetimestruct dts ndarray[int64_t] iresult ndarray[object] result_timezone int year, month, day, minute, hour, second, weekday, julian diff --git a/pandas/_libs/tslibs/timestamps.pxd b/pandas/_libs/tslibs/timestamps.pxd index 8e7380b37209e..e9e484c715f9a 100644 --- a/pandas/_libs/tslibs/timestamps.pxd +++ b/pandas/_libs/tslibs/timestamps.pxd @@ -2,10 +2,10 @@ # cython: profile=False from numpy cimport int64_t -from np_datetime cimport pandas_datetimestruct +from np_datetime cimport npy_datetimestruct cdef object create_timestamp_from_ts(int64_t value, - pandas_datetimestruct dts, + npy_datetimestruct dts, object tz, object freq) cdef int64_t _NS_UPPER_BOUND, _NS_LOWER_BOUND diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 864950ff03eae..be988e7247e59 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -29,7 +29,7 @@ from nattype import NaT from nattype cimport NPY_NAT from np_datetime import OutOfBoundsDatetime from np_datetime cimport (reverse_ops, cmp_scalar, check_dts_bounds, - pandas_datetimestruct, dt64_to_dtstruct) + npy_datetimestruct, dt64_to_dtstruct) from offsets cimport to_offset from timedeltas import Timedelta from timedeltas cimport delta_to_nanoseconds @@ -45,7 +45,7 @@ _no_input = object() cdef inline object create_timestamp_from_ts(int64_t value, - pandas_datetimestruct dts, + npy_datetimestruct dts, object tz, object freq): """ convenience routine to construct a Timestamp from its parts """ cdef _Timestamp ts_base @@ -973,7 +973,7 @@ class Timestamp(_Timestamp): """ cdef: - pandas_datetimestruct dts + npy_datetimestruct dts int64_t value, value_tz, offset object _tzinfo, result, k, v datetime ts_input