How to read a JSON file as a pandas DataFrame?

From your code, it looks like you’re loading a JSON file which has JSON data on each separate line. read_json supports a lines argument for data like this:

data_df = pd.read_json('C:/Users/Alberto/nutrients.json', lines=True)

Note
Remove lines=True if you have a single JSON object instead of individual JSON objects on each line.

Leave a Comment