Skip to content

to_datetime with format string cannot read nanoseconds #8989

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

xref #8904

In the format string, %f means microseconds (https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior), but this means the nanoseconds cannot be read in using a format string:

In [11]: pd.to_datetime("2012-01-01 09:00:00.000000001", format="%Y-%m-%d %H:%M:%S.%f")
-> 
ValueError: unconverted data remains: 001

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions