Title: Load A JSON File Into Pandas
Slug: load_json_file_into_pandas
Summary: How to quickly load a JSON file into pandas.
Date: 2016-08-31 12:00
Category: Python
Tags: Basics
Authors: Chris Albon

Preliminaries


In [1]:
# Load library
import pandas as pd

Load JSON File


In [2]:
# Create URL to JSON file (alternatively this can be a filepath)
url = 'https://raw.githubusercontent.com/chrisalbon/simulated_datasets/master/data.json'

# Load the first sheet of the JSON file into a data frame
df = pd.read_json(url, orient='columns')

# View the first ten rows
df.head(10)


Out[2]:
category datetime integer
0 0 2015-01-01 00:00:00 5
1 0 2015-01-01 00:00:01 5
10 0 2015-01-01 00:00:10 5
11 0 2015-01-01 00:00:11 5
12 0 2015-01-01 00:00:12 8
13 0 2015-01-01 00:00:13 9
14 0 2015-01-01 00:00:14 8
15 0 2015-01-01 00:00:15 8
16 0 2015-01-01 00:00:16 2
17 0 2015-01-01 00:00:17 1