Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
pd.Timedelta('PT100H')
Issue Description
An ISO 8601 duration string raises a ValueError when the hours or minutes part is longer than 2 digits.
There is an explicit check for the length of the hours and minute parts in the parser https://github.com/pandas-dev/pandas/blob/f9be5d90a6bb72f2d11f47046f483efbcd5a787e/pandas/_libs/tslibs/timedeltas.pyx#L883
A duration of 100 hours is obviously valid, pd.Timedelta(100, unit='hours')
works like expected.
Expected Behavior
import pandas as pd
assert pd.Timedelta('PT100H') == pd.Timedelta(100, unit='hours')
assert pd.Timedelta('PT100M') == pd.Timedelta(100, unit='minutes')
Installed Versions
Comment From: jbrockmendel
PR would be welcome.
What is "PT" in this context?
Comment From: rosstitmarsh
P
prefixes all ISO 8601 durations
T
separates the years/months/day parts from the hour/minute/second parts. As P1M
is one month but PT1M
is 1 minute.
Comment From: rosstitmarsh
Closing in favour of #51882