graphPaname/app/preprocessing.py

21 lines
431 B
Python
Raw Normal View History

2020-05-27 20:13:45 +02:00
from json import load
2020-05-27 20:45:21 +02:00
from pandas import json_normalize, DataFrame
2020-05-27 21:25:08 +02:00
from constants import files, columns
2020-05-27 20:13:45 +02:00
def open_json(dataset):
with open(files[dataset]) as f:
json = load(f)
return json
def create_dataframe(dataset):
json = open_json(dataset)
2020-05-27 21:25:08 +02:00
df = json_normalize(
data=json["records"],
record_path=["fields"],
meta=columns[dataset],
errors="ignore",
)
2020-05-27 20:13:45 +02:00
return df