Skip to content

BUG: empty strings raise in non-ISO8601 formats but parse as NaT elsewhere #50252

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 5 commits into from
Dec 16, 2022

Conversation

MarcoGorelli
Copy link
Member

Let's make this consistent. I think I prefer the former (NaT). ISO formats are probably also more common, so arguably this'd be a breaking change for fewer people

@MarcoGorelli MarcoGorelli added Bug Datetime Datetime data dtype labels Dec 14, 2022
def test_empty_string_datetime_coerce_format():
# GH13044
@pytest.mark.parametrize("errors", ["raise", "coerce", "ignore"])
def test_empty_string_datetime_coerce_format(errors):
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Maybe good to update this test name since coerce isn't the only errors argument being tested here

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

One comment otherwise this change looks reasonable.

Also though it might be redundant, might be good to have an independent test showing that iso & non-iso format with empty string produces NaT

@MarcoGorelli
Copy link
Member Author

good point, thanks - extra test added!

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

LGTM

@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Dec 15, 2022
@phofl phofl merged commit e0cb0b3 into pandas-dev:main Dec 16, 2022
@phofl
Copy link
Member

phofl commented Dec 16, 2022

thx @MarcoGorelli

phofl pushed a commit to phofl/pandas that referenced this pull request Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: empty strings raise in non-ISO8601 formats but parse as NaT elsewhere
4 participants