I have list of list
u=[[1, 1], [2, 1, 1, 1], [2, 2, 1, 1, 1, 1, 2, 2], [2, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2], [2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 3, 2, 3, 3, 3, 2, 2, 3, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2]]
I want to create a DataFrame using pandas where the rows are indexed by the length of u and the columns are given by the group of numbers inside this list of list.
I want the element of this DataFrame to be the frequency in which the elements occurs. For example, from above, I want to get the following table
In the Table above the column with 1 gives the number of ones in each list while 2 gives a number of 2. In cell (1,1) the number 2 was obtained by counting the number of ones in the first list that is [1,1]. In cell (2,1) the number 3 was obtained by counting a number of ones in the list [2,1,1,1] while in the cell (2,2) the number two was obtained by counting the frequency of two in the list [2,1,1,1] the same procedure was repeated throughout.
I know that to count number of repeating elements in a list I have to use count. for example [1,1,1,2].count(1)=3 what I want to know is to use Pandas so that I get the DataFrame as above. Is it possible to do this?