>> df.to_json(orient="split") '{"columns":[0],"index":["1","2","3"],"data":[[0],[1],[2]]}' >>> pd.read_json(df.to_json(orient="split"), orient="s...">

pd.read_json May Not Maintain Numeric String Index · Issue #28556 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@WillAyd

Description

@WillAyd

df = pd.DataFrame(range(3), index=list("123")) df.to_json(orient="split") '{"columns":[0],"index":["1","2","3"],"data":[[0],[1],[2]]}' pd.read_json(df.to_json(orient="split"), orient="split").index Int64Index([1, 2, 3], dtype='int64')

Note that the string nature of the values should be preserved via roundtrip here, but ends up being lossy anyway. Noted during refactor of #28510