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

INSTALLED VERSIONS ------------------ commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.11.1.final.0 python-bits : 64 pandas : 1.5.3 numpy : 1.24.2 pytz : 2022.7.1 dateutil : 2.8.2 setuptools : 65.5.0 pip : 22.3.1 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None zstandard : None tzdata : None

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