Skip to content

ENH: automatically detect orient= for read_json if not supplied #52713

@chrisjdixon

Description

@chrisjdixon

Feature Type

  • 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions