Timedelta not parsing ISO-8601 strings properly · Issue #29773 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
pd.Timedelta("P0DT1H") Timedelta('0 days 00:00:00')
and
pd.Timedelta("PT1H")
KeyError Traceback (most recent call last) pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.parse_timedelta_unit()
KeyError: ''
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last) in () ----> 1 pd.Timedelta("PT1H")
pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.Timedelta.new()
pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.parse_iso_format_string()
pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.timedelta_from_spec()
pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.parse_timedelta_unit()
ValueError: invalid unit abbreviation:
Problem description
The ISO strings should be parsed correctly and provide valid output
as described here and shown here
Expected Output
First example and second example should have output
Timedelta('0 days 01:00:00')
Output of pd.show_versions()
I had the same outputs locally and on google cola
Versions
INSTALLED VERSIONS
------------------
commit : None
python : 3.6.8.final.0
python-bits : 64
OS : Linux
OS-release : 4.14.137+
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.3
numpy : 1.17.4
pytz : 2018.9
dateutil : 2.6.1
pip : 19.3.1
setuptools : 41.6.0
Cython : 0.29.14
pytest : 3.6.4
hypothesis : None
sphinx : 1.8.5
blosc : None
feather : 0.4.0
xlsxwriter : None
lxml.etree : 4.2.6
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.7.6.1 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : 5.5.0
pandas_datareader: 0.7.4
bs4 : 4.6.3
bottleneck : 1.3.0
fastparquet : None
gcsfs : None
lxml.etree : 4.2.6
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : 2.5.9
pandas_gbq : 0.11.0
pyarrow : 0.14.1
pytables : None
s3fs : 0.4.0
scipy : 1.3.2
sqlalchemy : 1.3.11
tables : 3.4.4
xarray : 0.11.3
xlrd : 1.1.0
xlwt : 1.3.0
xlsxwriter : None