Skip to content

Instantly share code, notes, and snippets.

@avremel
Created May 17, 2018 19:25
Show Gist options
  • Save avremel/c54573d418ca9d809c6fe33542161814 to your computer and use it in GitHub Desktop.
Save avremel/c54573d418ca9d809c6fe33542161814 to your computer and use it in GitHub Desktop.
import more_itertools as mit
facets = {}
for k,v in raw_response['facet_counts']['facet_fields'].items():
spec_list = [list(spec) for spec in mit.chunked(v, 2)]
spec_dict = {}
for spec in spec_list:
spec_dict[spec[0]] = spec[1]
facets[k] = spec_dict
raw_response['facet_counts']['facet_fields'] = facets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment