Created
January 11, 2021 04:00
-
-
Save howard-haowen/b28c9dc3359cd03ce5cb1364a7e6303c to your computer and use it in GitHub Desktop.
Load json files to pandas dataframes
This file contains hidden or 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
import pandas as pd | |
import json | |
def create_df(file_path): | |
# read the JSON data using json.load() | |
with open(file_path) as json_file: | |
data_dict = json.load(json_file) | |
# convert json dataset from dictionary to dataframe | |
df = pd.DataFrame.from_dict(data_dict) | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment