Skip to content

Commit 846f0bf

Browse files
committed
PERF: rewrited _concat_date_cols function on C with removing extra conversation for integer/float zero and float NaN; rewrited _does_string_look_like_datetime on C
1 parent 707c720 commit 846f0bf

File tree

4 files changed

+457
-40
lines changed

4 files changed

+457
-40
lines changed

pandas/_libs/tslibs/parsing.pyx

+2-20
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ from dateutil.parser import parse as du_parse
3333
from pandas._libs.tslibs.ccalendar import MONTH_NUMBERS
3434
from pandas._libs.tslibs.nattype import nat_strings, NaT
3535

36+
from pandas._libs.datehelpers import _does_string_look_like_datetime
37+
3638
# ----------------------------------------------------------------------
3739
# Constants
3840

@@ -47,8 +49,6 @@ _DEFAULT_DATETIME = datetime(1, 1, 1).replace(hour=0, minute=0,
4749
cdef:
4850
object _TIMEPAT = re.compile(r'^([01]?[0-9]|2[0-3]):([0-5][0-9])')
4951

50-
set _not_datelike_strings = {'a', 'A', 'm', 'M', 'p', 'P', 't', 'T'}
51-
5252
# ----------------------------------------------------------------------
5353

5454
_get_option = None
@@ -187,24 +187,6 @@ cdef parse_datetime_string_with_reso(date_string, freq=None, dayfirst=False,
187187
return parsed, parsed, reso
188188

189189

190-
cpdef bint _does_string_look_like_datetime(object date_string):
191-
if date_string.startswith('0'):
192-
# Strings starting with 0 are more consistent with a
193-
# date-like string than a number
194-
return True
195-
196-
try:
197-
if float(date_string) < 1000:
198-
return False
199-
except ValueError:
200-
pass
201-
202-
if date_string in _not_datelike_strings:
203-
return False
204-
205-
return True
206-
207-
208190
cdef inline object _parse_dateabbr_string(object date_string, object default,
209191
object freq):
210192
cdef:

0 commit comments

Comments
 (0)