0

Suppose I have a list (or in this case a Series) that looks like this

[1,1,1,1,1,1,1,4,4,4,5,5,5,5,5,5,5,5,5,6,6,6,6,7,8,8,8,8,8]

I now want to convert this to a dict such that the key of the dict is the value of the list (here 1, 4, 5, 6, 7, 8) and that the value of the dict is the amount that the value of the list occures (here 7, 3, 9, 4, 1, 5).

I'd like to use a simple oneliner/list-comprehension but this topic is new to me for Python

Wouter Vandenputte
  • 1,948
  • 4
  • 26
  • 50

0 Answers0