Created
May 30, 2017 09:19
-
-
Save saraswatmks/8007548b63727146dce731126fe7e89d to your computer and use it in GitHub Desktop.
Json to Py Dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import json | |
import pandas as pd | |
file_name_1 = "train_data.json" | |
with open(file_name_1, 'r') as jsonfile1: | |
data_dict_1 = json.load(jsonfile1) | |
file_name_2 = "test_data.json" | |
with open(file_name_2, 'r') as jsonfile2: | |
data_dict_2 = json.load(jsonfile2) | |
train = pd.DataFrame.from_dict(data_dict_1, orient='index') | |
train.reset_index(level=0, inplace=True) | |
train.rename(columns = {'index':'ID'},inplace=True) | |
train.shape | |
test = pd.DataFrame.from_dict(data_dict_2, orient='index') | |
test.reset_index(level=0, inplace=True) | |
test.rename(columns = {'index':'ID'},inplace=True) | |
test.shape |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment