Skip to content

DEPR: casting strings to float in to_datetime with unit #50909

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 2 commits into from
Jan 26, 2023

Conversation

jbrockmendel
Copy link
Member

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Jan 23, 2023
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.

I guess this is okay (+0) although it makes to_datetime a little less convenient.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Looks good to me

Reckon the "inverse" should be deprecated as well, i.e. parsing numeric with format as strings, like

In [3]: to_datetime([20200101], format='%Y%m%d')
Out[3]: DatetimeIndex(['2020-01-01'], dtype='datetime64[ns]', freq=None)

?

Comment on lines +1216 to +1218
except OverflowError:
return data, False
except (TypeError, ValueError):
Copy link
Member

@MarcoGorelli MarcoGorelli Jan 24, 2023

Choose a reason for hiding this comment

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

is this just to avoid hitting the warning later in to_datetime(new_data, errors="raise", unit=date_unit), which would be outofbounds anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

correct

@jbrockmendel
Copy link
Member Author

Reckon the "inverse" should be deprecated as well, i.e. parsing numeric with format as strings, like

That definitely seems like a potential footgun, no idea how common that is in the wild.

@MarcoGorelli MarcoGorelli added the Datetime Datetime data dtype label Jan 26, 2023
@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Jan 26, 2023
@MarcoGorelli MarcoGorelli merged commit 8448d39 into pandas-dev:main Jan 26, 2023
@jbrockmendel jbrockmendel deleted the depr-unit-behavior branch January 26, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: to_datetime with unit changes how strings are interpreted
3 participants