Sunday, 15 February 2015

Fastest way to convert Python List with dictionaries to one dictionary -


I have parsed data in large amounts in the dictionary, which contains dictionaries. [123123: [0.45, 0.4]}, {2332: [0.1, 09]}]

I have around 800,000 records in this list, And I want to get a dictionary from:

  my_dict = {} for i in dict_list: for k, i.iteritems in v: my_dict [k] = v < / Code> 

There is one fast way to do this

Understand, like

  & gt; & Gt; & Gt; Dict_list = [{123123: [0.45, 0.4]}, {2332: [0.1, 9]}]> gt; & Gt; & Gt; {Key: Item [key] for key for item in dict_list}} {123123: [0.45, 0.4], 2332: [0.1, 9]}  

Since compiling with C Code is done, it should be sharply sharp with Python and then by changing the dictionary object.


No comments:

Post a Comment