SHARE
TWEET

Untitled

a guest Jun 24th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dict_1 = {'A': ['red', 'red', 'blue'],
  2.           'B': ['red', 'green'],
  3.           'C': ['blue', 'green'], ....}
  4.  
  5. dict_2 = {'A': Counter({'red': 2, 'blue': 1}),
  6.           'B': Counter({'red': 1, 'green': 1}),
  7.           'C': Counter({'blue': 1, 'green': 1}), ....}
  8.      
  9. fraction = {'A': [2/3, 1/3],
  10.             'B': [1/2, 1/2],
  11.             'C': [1/2, 1/2], ....}
  12.      
  13. fraction = { key: [v/len(colorz)] for namez, colorz in dict_1.items()
  14.                           for name, color in dict_2.items()
  15.                           for k, v in color.items() }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top