Reading JSON data into pandas

To read JSON data, pandas provides a method called read_json, where we pass the filename and location of the JSON data file we want to read. The file location can be local, or even on the internet with a valid URL scheme. We assign the resulting DataFrame to the variable DF.

The read_json method reads the JSON data and converts it into a pandas DataFrame  object, a tabular data format, as shown in the following code. The JSON data, which is now easily accessible in a DataFrame format, can be manipulated and explored with greater ease:

movies_json = pd.read_json('IMDB.json')movies_json.head()

The previous code block will produce the following output:

Get Mastering Exploratory Analysis with pandas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.