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

Timedelta ISO Format Constructor #19040

Closed
WillAyd opened this Issue Jan 2, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@WillAyd
Member

WillAyd commented Jan 2, 2018

Code Sample, a copy-pastable example if possible

In : pd.Timedelta('1 day').isoformat()
Out: 'P1DT0H0M0S'

In : pd.Timedelta(pd.Timedelta('1 day').isoformat())
Out: ValueError: invalid abbreviation: P

Problem description

A Timedelta can be formatted as an ISO 8601 Duration, but cannot be constructed from one. This makes it difficult to natively parse and convert any ISO 8601 Durations into their respective Timedelta objects.

For a specific example, write_json takes a Timedelta and writes it out in the ISO format, but read_json cannot reasonably parse that format back into a Timedelta object without such a constructor (see #19039)

INSTALLED VERSIONS

commit: 4319335
python: 3.6.1.final.0
python-bits: 64
OS: Darwin
OS-release: 17.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.0.dev0+31.g4319335aa
pytest: None
pip: 9.0.1
setuptools: 27.2.0
Cython: None
numpy: 1.13.1
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 6.1.0
sphinx: 1.6.5
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@WillAyd WillAyd referenced this issue Jan 2, 2018

Merged

read_json support for orient="table" #19039

4 of 4 tasks complete
@gfyoung

This comment has been minimized.

Member

gfyoung commented Jan 2, 2018

How odd! If you can make it possible, go for it!

@jreback

This comment has been minimized.

Contributor

jreback commented Jan 3, 2018

This was never implemented, a patch to do so would be straightorward & welcome.

@jreback jreback added this to the Next Major Release milestone Jan 3, 2018

@jreback jreback modified the milestones: Next Major Release, 0.23.0 Jan 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment