Parsing Python dictionary with multiple objects

Dave Angel davea at
Tue Oct 14 19:02:12 CEST 2014

anuragpatibandla7 at Wrote in message:
> I have a dictionary that looks like this:
> {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
> Now if I have 100 objects like these and I need to split them into 3 smaller dicts in a ratio 2:3:5, how could I do that?

I really have no idea what that means.  You have 100 dicts of
 dicts? Are the keys unique? If so, you could combine them with a
 loop of update.

> I tried using numpy.random.choice(), but it says it needs to be a 1-d array.

How about random.choice?  It needs a sequence.

To get anything more concrete, you need to specify Python version,
  and make a clearer problem statement,  perhaps with example of
 what you expect.


More information about the Python-list mailing list