Skip to content

Added improvements in to_datetime Error reporting message #47995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 16, 2022

Conversation

dannyi96
Copy link
Contributor

@dannyi96 dannyi96 commented Aug 6, 2022

  • closes The exceptions from to_datetime(errors='raise') could include information about the exception #16757

  • Changes description
    : For issue The exceptions from to_datetime(errors='raise') could include information about the exception #16757 - added more details in error message about field and its position causing the issue in pandas/_libs/tslib.pyx in array_to_datetime

  • Examples of changed error messages

    Code Old Error ( on 1.4.3 ) New Error
    pd.to_datetime(pd.Series(['2016-01-01', 'unparseable']), errors='raise') dateutil.parser._parser.ParserError: Unknown string format: unparseable dateutil.parser._parser.ParserError: Unknown string format: unparseable present at position 1
    pd.to_datetime(pd.Series(['2016-01-01', 'unparseable']), format='%Y-%m-%d', errors='raise') ValueError: time data unparseable doesn't match format specified ValueError: time data "unparseable" at position 1 doesn't match format specified
    pd.to_datetime(pd.Series(['2016-01-01', '12']), errors='raise') ValueError: Given date string not likely a datetime. ValueError: Given date string 12 not likely a datetime present at position 1

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reasons why you don’t continue in #47597 ?

@dannyi96
Copy link
Contributor Author

dannyi96 commented Aug 6, 2022

Any reasons why you don’t continue in #47597 ?

was suggested in the mentioned PR(#47597) to split the 3 issues for easier reviewing ( I probably should close the other PR )

@mroeschke mroeschke added Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas labels Aug 8, 2022
@dannyi96 dannyi96 marked this pull request as ready for review August 16, 2022 06:21
Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mroeschke mroeschke added this to the 1.5 milestone Aug 16, 2022
@mroeschke mroeschke merged commit 9dfbd9f into pandas-dev:main Aug 16, 2022
@mroeschke
Copy link
Member

Thanks @dannyi96

YYYasin19 pushed a commit to YYYasin19/pandas that referenced this pull request Aug 23, 2022
…#47995)

* pandas-dev#16757: improvement of to_datetime errors

* The exceptions from to_datetime(errors='raise') could include information about the exception

* testcase updates

* testcase updates

* testcase updates

* testcase updates
@dannyi96 dannyi96 deleted the todatetime_err_imp branch August 31, 2022 18:22
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
…#47995)

* pandas-dev#16757: improvement of to_datetime errors

* The exceptions from to_datetime(errors='raise') could include information about the exception

* testcase updates

* testcase updates

* testcase updates

* testcase updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The exceptions from to_datetime(errors='raise') could include information about the exception
3 participants