JSON is one of the most commong formats for transferring data, especially over the web. Many apis return json formats for data. Thus, pandas provides us with methods for working with json data and turning it into dataframes. In this article, we will learn how to read json using pandas.
To read json, we can pass either a json string or a file name to the read_json
method. In our example, we will read a local file into a dataframe. Pandas will take the file and create a dataframe for us.
import pandas as pd
import json
df = pd.read_json('./data.json')
print(df.head())