def flatten_properties(d):
for k, v in d['properties'].items():
if k == 'attribute-type':
continue
if k.startswith('property-'):
k = k[9:] # len('property-') == 9
k = k.replace('.', '_')
d[k] = v
del d['properties']
return d
df_titles = pd.DataFrame(
map(
flatten_properties,
cluedin.gql.entries(ctx, query, { 'query': 'entityType:/IMDb/Title', 'pageSize': 10_000 })))
Add cluedin.utils.flatten_properties method and use it by default for cluedin.gql.entries:
We already have the entries method:
Instead of writing this every time:
Add
cluedin.utils.flatten_properties
method and use it by default forcluedin.gql.entries
:Which is equivalent to: