Skip to content

pandas.DataFrame.to_json gives OverflowError when attempting to serialize datetime.time objects #4873

Closed
@jamescasbon

Description

@jamescasbon

datetime.time objects cause to_json to fail, presumably because they are attempting to be converted in the same way as datetime.datetime objects.

For example:

>>> pd.DataFrame(data=dict(a = [datetime.time()])).to_json()
...
OverflowError: Maximum recursion level reached

In contrast:

 >>> pd.DataFrame(data=dict(a = [datetime.datetime.now()])).to_json()
'{"a":{"0":1379498870147}}'

Tested on 0.12 and HEAD (b039c1d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDtype ConversionsUnexpected or buggy dtype conversionsIO JSONread_json, to_json, json_normalize

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions