2020-05-27 20:13:45 +02:00
|
|
|
from json import load
|
2020-06-12 19:21:50 +02:00
|
|
|
|
|
|
|
from pandas import DataFrame, json_normalize
|
|
|
|
|
|
|
|
from constants import COLUMNS, FILES
|
2020-06-13 18:23:34 +02:00
|
|
|
from app.data_request import request_dataset
|
2020-05-27 20:13:45 +02:00
|
|
|
|
|
|
|
|
2020-06-05 13:48:47 +02:00
|
|
|
def create_dataframe(dataset) -> DataFrame:
|
|
|
|
"""
|
|
|
|
Creates a DataFrame from a JSON file
|
|
|
|
"""
|
2020-06-13 21:58:17 +02:00
|
|
|
json = request_dataset(dataset)
|
2020-06-05 15:24:16 +02:00
|
|
|
df = json_normalize(data=json, record_path=["records"], errors="ignore",)
|
2020-06-10 21:48:44 +02:00
|
|
|
filtered_df = df.filter(items=COLUMNS[dataset])
|
|
|
|
return filtered_df
|