pd.read_json May Not Maintain Numeric String Index · Issue #28556 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
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