I am trying to count duplicates of each type of string in my framework. For example, let's say that I have a dataframe in pandas as follows:
df = pd.DataFrame({'one' : pd.Series([1., 1, 1]), 'two' : pd.Series([1., 2., 1] )})
I get a df that looks like this:
one two 0 1 1 1 1 2 2 1 1
I guess the first step is to find all the different unique strings that I do:
df.drop_duplicates()
This gives me the following df:
one two 0 1 1 1 1 2
Now I want to take each line from the above df ([1 1] and [1 2]) and count the number of times in each initial df. My result will look something like this:
Row Count [1 1] 2 [1 2] 1
How do I take this last step?
Edit:
Here is a more detailed example:
df = pd.DataFrame({'one' : pd.Series([True, True, True, False]), 'two' : pd.Series([True, False, False, True] ), 'three' : pd.Series([True, False, False, False] )})
gives me:
one three two 0 True True True 1 True False False 2 True False False 3 False False True
I need a result that tells me:
Row Count [True True True] 1 [True False False] 2 [False False True] 1