Skip to content

pd.to_timedelta unit ignored for string input #23716

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

Closed
jzwinck opened this issue Nov 15, 2018 · 4 comments
Closed

pd.to_timedelta unit ignored for string input #23716

jzwinck opened this issue Nov 15, 2018 · 4 comments
Labels
Bug Duplicate Report Duplicate issue or pull request Strings String extension data type and string data Timedelta Timedelta data type

Comments

@jzwinck
Copy link
Contributor

jzwinck commented Nov 15, 2018

In : pd.to_timedelta(123456789, unit='s')
Out: Timedelta('1428 days 21:33:09') # ok

In : pd.to_timedelta('123456789', unit='s')
Out: Timedelta('0 days 00:00:00.123456') # oops!

In : pd.to_timedelta('123.45', unit='s')
Out: ValueError('no units specified') # ???

Problem description

Evidently, the unit parameter is ignored when the input is a string (yet strings that look like numbers are accepted as if they were actually numbers).

Reproduced in Pandas 0.21.1 and 0.23.4.

@gfyoung gfyoung added Bug Timedelta Timedelta data type Strings String extension data type and string data labels Nov 15, 2018
@gfyoung
Copy link
Member

gfyoung commented Nov 15, 2018

How odd! Let's investigate and patch this. PR is definitely welcome.

@jreback
Copy link
Contributor

jreback commented Nov 15, 2018

ok look for a similar issue to this one

@mroeschke
Copy link
Member

xref #12136 #16791

@jorisvandenbossche jorisvandenbossche added the Duplicate Report Duplicate issue or pull request label Nov 21, 2018
@jorisvandenbossche jorisvandenbossche added this to the No action milestone Nov 21, 2018
@jorisvandenbossche
Copy link
Member

Lets close this as duplicate of #12136

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request Strings String extension data type and string data Timedelta Timedelta data type
Projects
None yet
Development

No branches or pull requests

5 participants