Grab the slides: slides.com/cheukting_ho/pandas-to-graph
4th December 2021, worldwide, 24 hours streaming, FREE
https://pyjamas.live
(other than that they are cute 💕)
(source: https://medium.com/swlh/converting-nested-json-structures-to-pandas-dataframes-e8106c59976e)
It's just not the best to handle nested data
np_to_buildin = {
v: getattr(builtins, k)
for k, v in np.typeDict.items()
if k in vars(builtins)
}
np_to_buildin[np.datetime64] = dt.datetime
with pd.read_csv(csv_file, sep=sep, chunksize=chunksize) as reader:
obj_list = df.to_dict(orient="records")
if any(df.isna().any()) and na == "error":
raise RuntimeError(
f"{df}\nThere is NA in the data and cannot be automatically load in. Use --na options to remove all records with NA or make properties optional to accept missing data."
)
elif na == "skip":
df.dropna(inplace=True)
if na == "optional":
bad_key = []
for key, value in item.items():
if pd.isna(value):
bad_key.append(key)
for key in bad_key:
item.pop(key)
df = pd.DataFrame().from_records(list(all_records))
expanded = pd.json_normalize(df[col])
expanded.columns = list(map(lambda x: col + "." + x, expanded))
df.drop(columns=col, inplace=True)
df = df.join(expanded)