Add dataframe creation
This commit is contained in:
parent
27031f8f03
commit
65c88d13a1
|
@ -1,2 +1,3 @@
|
|||
*/__pycache__
|
||||
Design.org
|
||||
data/*.json
|
||||
|
|
|
@ -9,3 +9,8 @@ filenames = {
|
|||
"deconfinement-pistes-cyclables-temporaires": "cycling-paths",
|
||||
"deconfinement-parking-relais-doublement-des-places": "relay-parking",
|
||||
}
|
||||
files = {
|
||||
"cycling-paths": "../data/cycling-paths.json",
|
||||
"relay-parking": "../data/relay-parking.json",
|
||||
"home-delivery": "../data/home-delivery.json",
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
from json import load
|
||||
from pandas import read_json, json_normalize, DataFrame
|
||||
from constants import files
|
||||
|
||||
|
||||
def open_json(dataset):
|
||||
with open(files[dataset]) as f:
|
||||
json = load(f)
|
||||
return json
|
||||
|
||||
|
||||
def create_dataframe(dataset):
|
||||
json = open_json(dataset)
|
||||
data = json_normalize(data=json["records"])
|
||||
df = DataFrame.from_dict(data=data)
|
||||
return df
|
Loading…
Reference in New Issue