The Python Oracle

use hour unit in pandas to_timedelta

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind

--

Chapters
00:00 Question
00:50 Accepted answer (Score 3)
01:13 Thank you

--

Full question
https://stackoverflow.com/questions/2559...

Accepted answer links:
[GH #7611]: https://github.com/pydata/pandas/issues/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #pandas

#avk47



ACCEPTED ANSWER

Score 3


[Moved from comments to close it:]

This was a bug, see GH #7611, and was fixed for 0.14.1:

>>> pd.__version__
'0.14.1'
>>> base = pd.to_datetime("00:00", format="%H:%M")
>>> base + pd.to_timedelta(1,unit='s')
Timestamp('1900-01-01 00:00:01')
>>> base + pd.to_timedelta(1,unit='h')
Timestamp('1900-01-01 01:00:00')