Load Json URL to Pandas DataFrame

Here is a super simple example of loading Json data from a URL into a Pandas DataFrame. If you don’t have Python easily accessible, you can try it out yourself online using this binder link running a Python Jupyter Notebook in a browser – Try it in Binder

import json  
import pandas as pd  
import requests

# Load JSON into a DataFrame given the URL to the JSON data
def load_json(url):
    r = requests.get(url)
    text = r.text
    jsdata = json.loads(text)
    return pd.json_normalize(jsdata)
            
df = load_json('https://raw.githubusercontent.com/prust/wikipedia-movie-data/master/movies.json')
df

Links

Leave a Comment

Your email address will not be published. Required fields are marked *