Skip to content

pd.read_json With convert_axes Produces Different Index Type than Empty Frame #28558

Closed
@WillAyd

Description

@WillAyd

Another edge case brought up by #28510 . I'm not sure if we have a definite stance on this and there are probably a few other issues that are similar, though couldn't find anything exactly matching this

Note the index types for an empty data frame

>>> df = pd.DataFrame()
>>> df.index
Index([], dtype='object')
>>> df.columns
Index([], dtype='object')

In read_json with convert_axes the axes labels end up with a different dtype

>>> for orient in ["columns", "index", "records", "values", "split"]:
...     print(pd.read_json("{}", orient=orient, convert_axes=True).columns)
...
Float64Index([], dtype='float64')
Float64Index([], dtype='float64')
Float64Index([], dtype='float64')
Float64Index([], dtype='float64')
Float64Index([], dtype='float64')

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO JSONread_json, to_json, json_normalizeMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNeeds TestsUnit test(s) needed to prevent regressionsgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions