خرید بک لینک

Vote count: 0

I have a dictionary d with 100 keys where the values are variable length lists, e.g.

 In[165]: d.values()[0]
 Out[165]: 
 [0.0432,
  0.0336,
  0.0345,
  0.044,
  0.0394,
  0.0555]

 In[166]: d.values()[1]
 Out[166]: 
 [0.0236,
  0.0333,
  0.0571]

Here's what I'd like to do: for every list in d.values(), I'd like to organize the values into 10 bins (where a value gets tossed into a bin if it satisfies the criteria, e.g. is between 0.03 and 0.04).

What'd I'd like to end up with is something that looks exactly like d, but instead of d.values()[0] being a list of numbers, I'd like it to be a list of lists, like so:

 In[167]: d.values()[0]
 Out[166]:
 [[0.0432, 0.044],
  [0.394, 0.0336, 0.0345],
  [0.0555]]

Each key would still be associated with the same values, but they'd be structured into the 10 bins.

I've been going crazy with nested for loops and if/elses, etc. What is the best way to go about this?

asked 53 secs ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: جمعه 7 اسفند 1394 ساعت: 3:58

صفحه بندی