Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
3 answers
1k views

Flatten the nested dictionary, which has list also, into a dictionary

I have a nested dictionary with a list inside of it such as {'Ka': {'Ka': ['0.80', '0.1'], 'Ba': ['0.50', '1.1'], 'FC': ['0.78', '0.0'], 'AA': ['0.66', '8.1']}, 'AL': {'AR': ['2.71', '7.3'], '...
Yag_r's user avatar
  • 67
10 votes
3 answers
23k views

Python 3: Flattening nested dictionaries and lists within dictionaries

I am dealing with a complex nested dictionary and list data structure. I need to flatten the data and bring all nested items to level 0. See below example for more clarity : {a:1,b:2,c:{c1:[{c11:1,...
Ashish Kohli's user avatar
-1 votes
2 answers
329 views

Python - JSON to nested and flatten dictionary

I'm new in Python and currently trying to read the following JSON: "level1_key1":"1", "level1_key2":{ "level2_key1":"2", "level2_key2":{ "level3_key1":"Max depth" } } then put it ...
Aktan A.'s user avatar
0 votes
2 answers
127 views

Creating a new dictionary from mapping of flattened nested dictionary

I was wondering if there is a quick and pythonic way to create a dictionary based on certain keys of a dictionary? For instance, if I have this given dictionary { "a": "abc", "b": {"b1": "1", "...
Liondancer's user avatar
  • 16.5k