Skip to content
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

pd.Timedelta() cannot process offset alias T while pd.infer_freq() return this format. #21762

Closed
elboerto opened this issue Jul 6, 2018 · 1 comment · Fixed by #23439
Closed
Labels
API Design Datetime Datetime data dtype Timedelta Timedelta data type
Milestone

Comments

@elboerto
Copy link

elboerto commented Jul 6, 2018

Code Sample, a copy-pastable example if possible

import pandas as pd
series = pd.Series([1, 2, 3], pd.date_range('201701010000', '201701010030', freq='15min'))
print(pd.infer_freq(series.index))
# Error
pd.Timedelta(pd.infer_freq(series.index))
# While this works
pd.Timedelta(series.index.freq)

Problem description

pd.Timedelta constructor works with e.g. '15min' but not with '15T',
while pd.infer_freq() returns '15T' and pd.Series.index.freq returns '15min'.
This leads to errors.

Expected Output

Same behaviour of pd.Timedelta() for 'min' and 'T' offset alias or deprecation of 'T' as an offset alias.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.4.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 142 Stepping 9, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.23.1 pytest: 3.6.2 pip: 10.0.1 setuptools: 39.2.0 Cython: None numpy: 1.14.5 scipy: 1.1.0 pyarrow: None xarray: None IPython: 6.4.0 sphinx: None patsy: None dateutil: 2.7.3 pytz: 2018.5 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 2.2.2 openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: None sqlalchemy: None pymysql: None psycopg2: None jinja2: None s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
@gfyoung gfyoung added Datetime Datetime data dtype API Design labels Jul 6, 2018
@gfyoung
Copy link
Member

gfyoung commented Jul 6, 2018

Weird! My first inclination is to accept T as an offset.

cc @jreback

@jbrockmendel jbrockmendel added the Timedelta Timedelta data type label Jul 10, 2018
@jreback jreback added this to the 0.24.0 milestone Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Datetime Datetime data dtype Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants