Python Forum

Full Version: Pandas find the most often rows
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.
I have a panda Data Frame like the one below
smallData=pd.DataFrame(np.array([[1,2,3,4,5],[4,5,6,7,8],[1,2,3,3,3],[1,2,2,3,3],[1,2,3,5,3],[1,2,3,5,3]]),columns=['1', '2','3','4','5'])
and I would like to find which are the most frequent sequences, where each row is considered a 5 step sequence.

I do not want to find only the most frequent one but for each sequence to get back a number of how frequent it appeared.

Any suggestions?
Regards
Alex
Don't make a dataframe. Make it a list of tuples, and run it through collections.Counter.