I am currently trying to find the count of pair occurrences in a dictionary where each key has more than one value.
example, here is a dict:
df_dict = {
'apple': ['1.0', '3.0'],
'banana': ['2.0', '5.0'],
'orange': ['1.0', '3.0'],
'plum': ['2.0', '1.0']
}
result that I want:
['1.0', '3.0']: 2 ['2.0', '5.0']: 1 ['2.0', '1.0']: 1
where apple and orange have the same pair value.
Here is what I tried but result does not match with what I want.
def pair_count(df_dict):
count = 0
for k, v in df_dict.items():
if len(set(v))' != 1:
for idx in v:
if idx == '1.0':
count = count + 1
print(v, count)
Thank you for your time and help.