Skip to content

JSON: handling missing values in date coercion #10747

Closed
@jreback

Description

@jreback

xref #10746

In [1]: data = '''
   ...: [{"id": 1, "timestamp": 1036713600000},
   ...:  {"id": 2}]
   ...: '''

after #10776 this is ok

In [2]: pd.read_json(StringIO(data), orient='records', dtype={'id': 'int32', 'timestamp': 'datetime64[ms]'})
Out[2]: 
   id     timestamp
0   1  1.036714e+12
1   2           NaN

In [2]: pd.read_json(StringIO(data), orient='records', dtype={'id': 'int32', 'timestamp': 'datetime64[ms]'})
Out[10]: 
   id  timestamp
0   1 2002-11-08
1   2        NaT

still open

In [7]: pd.read_json(StringIO(data), orient='records', date_unit='ms')
Out[7]: 
   id     timestamp
0   1  1.036714e+12
1   2           NaN

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypeIO JSONread_json, to_json, json_normalize

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions