Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WillAyd opened this issue Sep 21, 2019 · 2 comments · Fixed by #53242
Closed

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

WillAyd opened this issue Sep 21, 2019 · 2 comments · Fixed by #53242
Labels
good first issue IO JSON read_json, to_json, json_normalize Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Needs Tests Unit test(s) needed to prevent regressions

Comments

@WillAyd
Copy link
Member

WillAyd commented Sep 21, 2019

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')
@WillAyd WillAyd added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Dtype Conversions Unexpected or buggy dtype conversions IO JSON read_json, to_json, json_normalize labels Sep 21, 2019
@mroeschke mroeschke added the Bug label May 8, 2020
@mroeschke
Copy link
Member

This looks to match the empty case now. Could use a test

@mroeschke mroeschke added good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Bug Dtype Conversions Unexpected or buggy dtype conversions labels Apr 28, 2023
@mcgeestocks
Copy link
Contributor

@mroeschke I could take that. I'm on the hunt for a good first issue, test writing seems like a great place to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue IO JSON read_json, to_json, json_normalize Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants