Add dataframe creation

This commit is contained in:
coolneng 2020-05-27 20:13:45 +02:00
parent 27031f8f03
commit 65c88d13a1
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
3 changed files with 22 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*/__pycache__
Design.org
data/*.json

View File

@ -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",
}

16
app/preprocessing.py Normal file
View File

@ -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