Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
As seen in #29102 (the rejected #29104), and then #46718, determining user intent in user input from pd.read_json(some_string)
is in general not possible. #46718 is a halfway house in that it explicitly marks some "file extensions" as "you probably wanted to read from a file", but is easily defeated by, for example pd.read_json("missing.jsonl", lines=True)
(jsonl
being a common extension for "lines"-formatted json files).
AFAICT, read_json
is the only read_XXX
function that accepts a literal representation of the data in its path_or_buf
argument, so there doesn't seem to be a great deal of precedent here.
Feature Description
Deprecate literal json input to pd.read_json
, if one wants to read from a string it should be wrapped in a StringIO.
e.g.
import pandas as pd
from io import StringIO
data = '{"a":{"0":1}}'
# old, proposed for deprecation
df = pd.read_json(data)
# new
df = pd.read_json(StringIO(data))
Alternative Solutions
None
Additional Context
No response