I have a list of lists like the following:
listoflist = [["A", "B", "A", "C", "D"], ["Z", "A", "B", "C"], ["D", "D", "X", "Y", "Z"]]
I want to find the number of sublists that each unique value in listoflist
occurs in. For example, "A" shows up in two sublists, while "D" shows up in two sublists also, even though it occurs twice in listoflist[3]
.
How can I get a dataframe which has each unique element in one column and the frequency (number of sublists each unique element shows up in)?