Code Sample, a copy-pastable example if possible
>>> pd.Timedelta(1, 'd')
Timedelta('1 days 00:00:00')
>>> pd.Timedelta('1d')
Timedelta('1 days 00:00:00')
>>> pd.Timedelta(1, 'Y')
Timedelta('365 days 05:49:12')
>>> pd.Timedelta('1Y')
Traceback (most recent call last):
File "pandas/_libs/tslibs/timedeltas.pyx", line 294, in pandas._libs.tslibs.timedeltas.timedelta_from_spec
KeyError: 'y'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/_libs/tslib.pyx", line 2588, in pandas._libs.tslib.Timedelta.__new__
File "pandas/_libs/tslibs/timedeltas.pyx", line 251, in pandas._libs.tslibs.timedeltas.parse_timedelta_string
File "pandas/_libs/tslibs/timedeltas.pyx", line 296, in pandas._libs.tslibs.timedeltas.timedelta_from_spec
ValueError: invalid abbreviation: Y
Problem description
Units beyond day
(e.g., week
month
year
) are not supported in timedelta_abbrevs
, but explicitly specifying by param unit=
is supported.
Is it OK to add supported of they in timedelta_abbrevs
too?
Expected Output
Output of pd.show_versions()
[paste the output of ``pd.show_versions()`` here below this line]
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Darwin
OS-release: 17.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: zh_CN.UTF-8
LOCALE: zh_CN.UTF-8
pandas: 0.21.1
pytest: None
pip: 9.0.1
setuptools: 36.5.0
Cython: None
numpy: 1.13.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: 1.0.2
lxml: None
bs4: 4.6.0
html5lib: None
sqlalchemy: None
pymysql: 0.7.11.None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
Comment From: jreback
see #16344 we want to remove these entirely; these are not fixed lengths of time and thus very confusing for a Timedelta.
Comment From: jreback
certainly welcome for a PR on #16344