Skip to content

BUG: to_json failing on mixed with Timedelta #9027

Closed
@jreback

Description

@jreback
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO JSONread_json, to_json, json_normalizeTimedeltaTimedelta data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions