Skip to content

ENH/PERF: new kw complete to to_datetime to allow partial matches on a datetime format #8903

Closed
@jreback

Description

@jreback

Clearly the default is complete=True for back-compat
but allows for a match starting at the beginning (has always been like this),
but doesn't require the string to ONLY match the format, IOW, can be extra stuff after the match.

Avoids having to do a regex replace first.

In [21]: s = Series(['19MAY11','19MAY11:00:00:00']*100000)

In [22]: %timeit pd.to_datetime(s.str.replace(':\S+$',''),format='%d%b%y')
1 loops, best of 3: 828 ms per loop

In [23]: %timeit pd.to_datetime(s,format='%d%b%y',compete=False)
1 loops, best of 3: 603 ms per loop

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDatetimeDatetime data dtypePerformanceMemory or execution speed performanceStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions