@@ -209,7 +209,7 @@ cdef object _parse_delimited_date(str date_string, bint dayfirst):
209
209
raise DateParseError(f" Invalid date specified ({month}/{day})" )
210
210
211
211
212
- cdef bint does_string_look_like_time (str parse_string):
212
+ cdef bint _does_string_look_like_time (str parse_string):
213
213
"""
214
214
Checks whether given string is a time: it has to start either from
215
215
H:MM or from HH:MM, and hour and minute values must be valid.
@@ -249,7 +249,6 @@ def parse_datetime_string(
249
249
str date_string ,
250
250
bint dayfirst = False ,
251
251
bint yearfirst = False ,
252
- **kwargs ,
253
252
) -> datetime:
254
253
"""
255
254
Parse datetime string , only returns datetime.
@@ -266,10 +265,10 @@ def parse_datetime_string(
266
265
if not _does_string_look_like_datetime(date_string ):
267
266
raise ValueError (f' Given date string "{date_string}" not likely a datetime' )
268
267
269
- if does_string_look_like_time (date_string):
268
+ if _does_string_look_like_time (date_string):
270
269
# use current datetime as default, not pass _DEFAULT_DATETIME
271
270
dt = du_parse(date_string, dayfirst = dayfirst,
272
- yearfirst = yearfirst, ** kwargs )
271
+ yearfirst = yearfirst)
273
272
return dt
274
273
275
274
dt, _ = _parse_delimited_date(date_string, dayfirst)
@@ -294,7 +293,7 @@ def parse_datetime_string(
294
293
295
294
try :
296
295
dt = du_parse(date_string, default = _DEFAULT_DATETIME,
297
- dayfirst = dayfirst, yearfirst = yearfirst, ** kwargs )
296
+ dayfirst = dayfirst, yearfirst = yearfirst)
298
297
except TypeError :
299
298
# following may be raised from dateutil
300
299
# TypeError: 'NoneType' object is not iterable
@@ -667,9 +666,7 @@ cdef dateutil_parse(
667
666
# Parsing for type-inference
668
667
669
668
670
- def try_parse_dates (
671
- object[:] values , parser , bint dayfirst = False , default = None ,
672
- ) -> np.ndarray:
669
+ def try_parse_dates (object[:] values , parser ) -> np.ndarray:
673
670
cdef:
674
671
Py_ssize_t i , n
675
672
object[::1] result
@@ -705,47 +702,6 @@ def try_parse_year_month_day(
705
702
return result.base # .base to access underlying ndarray
706
703
707
704
708
- def try_parse_datetime_components (object[:] years ,
709
- object[:] months ,
710
- object[:] days ,
711
- object[:] hours ,
712
- object[:] minutes ,
713
- object[:] seconds ) -> np.ndarray:
714
-
715
- cdef:
716
- Py_ssize_t i , n
717
- object[::1] result
718
- int secs
719
- double float_secs
720
- double micros
721
-
722
- n = len (years)
723
- # TODO(cython3 ): Use len instead of `shape[0 ]`
724
- if (
725
- months.shape[0 ] != n
726
- or days.shape[0 ] != n
727
- or hours.shape[0 ] != n
728
- or minutes.shape[0 ] != n
729
- or seconds.shape[0 ] != n
730
- ):
731
- raise ValueError (" Length of all datetime components must be equal" )
732
- result = np.empty(n, dtype = " O" )
733
-
734
- for i in range (n):
735
- float_secs = float (seconds[i])
736
- secs = int (float_secs)
737
-
738
- micros = float_secs - secs
739
- if micros > 0 :
740
- micros = micros * 1000000
741
-
742
- result[i] = datetime(int (years[i]), int (months[i]), int (days[i]),
743
- int (hours[i]), int (minutes[i]), secs,
744
- int (micros))
745
-
746
- return result.base # .base to access underlying ndarray
747
-
748
-
749
705
# ----------------------------------------------------------------------
750
706
# Miscellaneous
751
707
@@ -1001,6 +957,7 @@ cdef str _fill_token(token: str, padding: int):
1001
957
token_filled = f" {seconds}.{nanoseconds}"
1002
958
return token_filled
1003
959
960
+
1004
961
cdef void _maybe_warn_about_dayfirst(format: str , bint dayfirst):
1005
962
""" Warn if guessed datetime format doesn't respect dayfirst argument."""
1006
963
cdef:
@@ -1062,16 +1019,13 @@ cdef object convert_to_unicode(object item, bint keep_trivial_numbers):
1062
1019
1063
1020
@ cython.wraparound (False )
1064
1021
@ cython.boundscheck (False )
1065
- def concat_date_cols (tuple date_cols , bint keep_trivial_numbers = True ) -> np.ndarray:
1022
+ def concat_date_cols (tuple date_cols ) -> np.ndarray:
1066
1023
"""
1067
1024
Concatenates elements from numpy arrays in `date_cols` into strings.
1068
1025
1069
1026
Parameters
1070
1027
----------
1071
1028
date_cols : tuple[ndarray]
1072
- keep_trivial_numbers : bool , default True
1073
- if True and len(date_cols ) == 1, then
1074
- conversion (to string from integer/float zero ) is not performed
1075
1029
1076
1030
Returns
1077
1031
-------
@@ -1110,8 +1064,7 @@ def concat_date_cols(tuple date_cols, bint keep_trivial_numbers=True) -> np.ndar
1110
1064
it = < flatiter> PyArray_IterNew(array)
1111
1065
for row_idx in range (rows_count):
1112
1066
item = PyArray_GETITEM(array, PyArray_ITER_DATA(it))
1113
- result_view[row_idx] = convert_to_unicode(item,
1114
- keep_trivial_numbers)
1067
+ result_view[row_idx] = convert_to_unicode(item, True )
1115
1068
PyArray_ITER_NEXT(it)
1116
1069
else :
1117
1070
# create fixed size list - more efficient memory allocation
0 commit comments