Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: datetime parsing: error message indicating position of conflicting string is wrong for larger data #55345

Copy link
Copy link
Open
@jorisvandenbossche

Description

@jorisvandenbossche
Issue body actions

Using the latest pandas main (and also happens on released version 2.1.1):

In [1]: pd.to_datetime(["2012-01-01"] * 49 + ["2012-01-02 09"])
...
ValueError: unconverted data remains when parsing with format "%Y-%m-%d": " 09", at position 49. You might want to try:
    - passing `format` if your strings have a consistent format;
    - passing `format='ISO8601'` if your strings are all ISO8601 but not necessarily in exactly the same format;
    - passing `format='mixed'`, and the format will be inferred for each element individually. You might want to use `dayfirst` alongside this.

In [2]: pd.to_datetime(["2012-01-01"] * 50 + ["2012-01-02 09"])
...
ValueError: unconverted data remains when parsing with format "%Y-%m-%d": " 09", at position 1. You might want to try:
...

In the first case, it correctly says "position 49", while in the second case (n > 50), it confusingly says "position 1".

Metadata

Metadata

Assignees

Labels

BugDatetimeDatetime data dtypeDatetime data dtypeError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandas

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.