Skip to content

Add abbrs for ['Y', 'M', 'W'] in Timedelta #19090

New issue

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

Closed
holymonson opened this issue Jan 5, 2018 · 2 comments
Closed

Add abbrs for ['Y', 'M', 'W'] in Timedelta #19090

holymonson opened this issue Jan 5, 2018 · 2 comments
Labels
Deprecate Functionality to remove in pandas Timedelta Timedelta data type

Comments

@holymonson
Copy link
Contributor

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

@jreback
Copy link
Contributor

jreback commented Jan 5, 2018

see #16344 we want to remove these entirely; these are not fixed lengths of time and thus very confusing for a Timedelta.

@jreback jreback closed this as completed Jan 5, 2018
@jreback jreback added Deprecate Functionality to remove in pandas Timedelta Timedelta data type labels Jan 5, 2018
@jreback jreback added this to the No action milestone Jan 5, 2018
@jreback
Copy link
Contributor

jreback commented Jan 5, 2018

certainly welcome for a PR on #16344

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Timedelta Timedelta data type
Projects
None yet
Development

No branches or pull requests

2 participants