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

BUG: to_json failing on mixed with Timedelta #9027

Closed
jreback opened this issue Dec 6, 2014 · 1 comment · Fixed by #9028
Closed

BUG: to_json failing on mixed with Timedelta #9027

jreback opened this issue Dec 6, 2014 · 1 comment · Fixed by #9028
Labels
IO JSON read_json, to_json, json_normalize Timedelta Timedelta data type
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Dec 6, 2014

In [6]: df = DataFrame({'A' : [pd.Timedelta('1 day 1 sec')],'B' : [5], 'C' : [pd.Timestamp('20130101') ]})

In [7]: df
Out[7]: 
                A  B          C
0 1 days 00:00:01  5 2013-01-01

In [8]: df.dtypes
Out[8]: 
A    timedelta64[ns]
B              int64
C     datetime64[ns]
dtype: object

In [9]: df[['A']].to_json()
Out[9]: '{"A":{"0":86401000}}'

In [10]: df.to_json(default_handler=lambda x: x.asm8)
Out[10]: '{"A":{"0":86401000000000},"B":{"0":5},"C":{"0":1356998400000}}'

In [11]: df.to_json()
OverflowError: Maximum recursion level reached
@jreback jreback added IO JSON read_json, to_json, json_normalize Timedelta Timedelta data type labels Dec 6, 2014
@jreback jreback added this to the 0.16.0 milestone Dec 6, 2014
@jreback
Copy link
Contributor Author

jreback commented Dec 6, 2014

@Komnomnomnom

its currently using the datetime handler, so works in a single dtyped case.

side issue is that you are doing .values on the entire frame?

you need to go column-by-column. Much more efficient (we can do this in python an present a simpler view)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO JSON read_json, to_json, json_normalize Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant