Python venn package: what format should dataset_dict be?

269 Views Asked by At

So I have several lists that contain ID numbers, let's suppose them to look like this:

list_a=[1,2,3,4,5,6,7,8,9,10]
list_b=[1,3,5,7,9]
list_c=[2,4,6,8,10]
list_d=[1,11,2,22,3,33]

My task is to visualize these lists as venn diagrams to show intersection of ID numbers. Thus, i decided to use venn package from python, which has following function:

venn(dataset_dict, **kwargs)

I tried to use it this way:

venn(dict({'List A':list_a, 'List B':list_b, 'List C':list_c, 'List D':list_d}))

But error below is occuring:

TypeError: Only dictionaries of sets are understood

I see that the problem is with 'dataset_dict', how can i improve it?

1

There are 1 best solutions below

0
On BEST ANSWER

As the error implies, you are passing data with the wrong type. Your values in the dict passed to venn() are of type list, not set. You could do :

venn({'List A': set(list_a), ...})