Feature Type

  • [X] Adding new functionality to pandas

  • [ ] Changing existing functionality in pandas

  • [ ] Removing existing functionality in pandas

Problem Description

We'd love for Pandas to automatically detect what orient= should be for read_json if the orient was 'table' or 'split' and the argument wasn't supplied (seems unsupported as of 2.0.0).

Feature Description

For example, this would ideally not throw "ValueError: Mixing dicts with non-Series may lead to ambiguous ordering.", and instead work as if orient='table' was supplied to read_json:

import pandas as pd

df = pd.DataFrame({"A": [1, 2, 3],})
df.to_json('test.json', indent=1, orient= 'table')
read = pd.read_json('test.json')
print(read)

Alternative Solutions

I'm sorry but I'm not much of a programmer and wouldn't know where to begin designing a solution. Some except block that trys on the ValueError?

Additional Context

This isn't a huge problem but it recently caused several beginners many headaches and would be a subtle improvement to Pandas overall. If this is an easy fix then great, otherwise sorry for the dumb suggestion!

Comment From: csreddy98

Are you suggesting that pandas should allow something like pd.read_json('test.json', orient='auto_detect') and parse the json file automatically?

Yes, that would be a cool new add-on.

Comment From: jesse-sealand

I work with a lot of json and this would be a great enhancement.

Comment From: chandra-teajunkie

Hi, I would like to try working on this, if its still considered a valuable feature.

Comment From: WillAyd

Thank you for the suggestion, but we generally are moving away from inferring user intent and pushing towards more explicit usage of pandas. The request here is unfortunately misaligned with the overall direction of the project