I'm very familiar with how to return value_counts
from a pd.Series
. However, how would I get the value counts from values of a dictionary?
Say that I have the following tuples in dictionary L
:
L = {1: (13600, 14797),
2: (14700, 14700),
3: (14700, 10400),
4: (14600, 17200),
5: (13600, 14797),
6: (14600, 17200),
7: (14700, 10400),
8: (14700, 10400),
9: (12800, 14770)}
How do I get the value_counts
from L
that would look like:
(14700, 10400) 3
(13600, 14797) 2
(14600, 17200) 2
(14700, 14700) 1
(12800, 14770) 1
This is what I have so far. However, I think the dictionary keys 1-9 are getting in the way because I get the error list object is not callable.
list = [(k, v) for k, v in L.items()]
S = set(L)
F = {}
for i in list(S):
F[i] = list.count(i)