jquery - flatten a deep json structure with jq for pandas -


i trying flatten json file pandas dataframe , found solution here. in case json has many different attributes seems tedious spell out rule every field manually. isn't possible flatten every attribute in json file automatically?

i made solve similar problem. might not work in case, maybe take similar approach.

def nested_dataframe(d):     assert type(d) dict  # may nested dict     types = map(type, d.values())     if dict not in types:         # 1 un-nested dict. make dataframe.         return dataframe.from_dict({k: list([v]) k, v in d.items()}, orient='index')     if all([t dict t in types]):         # dict of dicts.         # call nested_dataframe on each item, , concatenate results.         return pd.concat([nested_dataframe(a) in d.values()], keys=d.keys())     else:         raise valueerror("this doesn't work on dicts unequal depths.") 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -