You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importpandasaspd# Raises an error for >2 digit hours or minutespd.Timedelta('PT100H')
pd.Timedelta('PT100M')
# Incorrectly parses any decimal component apart from secondspd.Timedelta('PT3.5H') ==pd.Timedelta('PT5H3S')
# Raises an error for comma as decimal separatorpd.Timedelta('PT3,5H')
# Does not raise an error for plusses in numberspd.Timedelta('P+1S') ==pd.Timedelta('PT1S')
# Does not raise an error for unsupported month component, instead parses it as minutespd.Timedelta('P1M') ==pd.Timedelta('PT1M')
# Does not raise an error for hour and second components before the 'T' seperatorpd.Timedelta('P1H') ==pd.Timedelta('PT1H')
pd.Timedelta('P1S') ==pd.Timedelta('PT1S')
# Does not raise an error for day components after the 'T' seperatorpd.Timedelta('PT1D') ==pd.Timedelta('P1D')
# Does not raise an error for duplicate components (and produces unexpected result)pd.Timedelta('PT1S1S1S1S') ==pd.Timedelta('PT20M34S')
# Does not raise an error for components in the incorrect orderpd.Timedelta('PT1M1H') ==pd.Timedelta('PT1H1M')
# Does not raise an error for trailing 'T' separatorpd.Timedelta('P1DT') ==pd.Timedelta('P1D')
# Does not raise an error for duplicate 'T' separatorspd.Timedelta('PTTT1H') ==pd.Timedelta('PT1H')
# Does not raise an error for 'P' or 'T' in any positionpd.Timedelta('PTP1TPTH') ==pd.Timedelta('PT1H')
# Bad numberspd.Timedelta("PT.1S")
pd.Timedelta("PT+1S")
# Bad componentspd.Timedelta("P1M")
pd.Timedelta("P1H")
pd.Timedelta("P1S")
pd.Timedelta("PT1D")
pd.Timedelta("PT1M1H")
pd.Timedelta("P1S1S")
# Misplaced P or Tpd.Timedelta("P1PD")
pd.Timedelta("P1TD")
pd.Timedelta("P1DT")
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
Numbers
pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 883 in f9be5d9
,
as a decimal separator+
) to prefix numbers, this is outwith the standard.pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 880 in f9be5d9
Components
M
) components as minutes.pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 885 in f9be5d9
H
) or second (S
) components before theT
T
P
andT
symbolsP
andT
symbols anywhere in the string.pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 873 in f9be5d9
Expected Behavior
The follwing should all parse without errors.
The follwing should all raise errors.
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: