We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
import pandas as pd pd.Timedelta('PT100H')
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
pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 883 in f9be5d9
A duration of 100 hours is obviously valid, pd.Timedelta(100, unit='hours') works like expected.
pd.Timedelta(100, unit='hours')
import pandas as pd assert pd.Timedelta('PT100H') == pd.Timedelta(100, unit='hours') assert pd.Timedelta('PT100M') == pd.Timedelta(100, unit='minutes')
commit : 2e218d1 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
The text was updated successfully, but these errors were encountered:
PR would be welcome.
What is "PT" in this context?
Sorry, something went wrong.
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.
P
T
P1M
PT1M
Closing in favour of #51882
No branches or pull requests
Pandas version checks
I have checked that this issue has not already been reported.
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
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
pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 883 in f9be5d9
A duration of 100 hours is obviously valid,
pd.Timedelta(100, unit='hours')
works like expected.Expected Behavior
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
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
The text was updated successfully, but these errors were encountered: