Python Forum
Pandas find the most often rows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas find the most often rows
#1
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
Reply
#2
Don't make a dataframe. Make it a list of tuples, and run it through collections.Counter.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How is pandas modifying all rows in an assignment - python-newbie question markm74 1 653 Nov-28-2023, 10:36 PM
Last Post: deanhystad
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 797 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,599 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,226 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  How to combine multiple rows of strings into one using pandas? shantanu97 1 3,096 Aug-22-2021, 05:26 AM
Last Post: klllmmm
  Python Pandas: How do I sumproduct by rows with an if condition? JaneTan 2 5,278 Jul-13-2021, 11:36 AM
Last Post: jefsummers
  Partial Matching Rows In Pandas DataFrame Query eddywinch82 1 2,338 Jul-08-2021, 06:32 PM
Last Post: eddywinch82
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,082 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 6,958 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
  Pandas: how to split one row of data to multiple rows and columns in Python GerardMoussendo 4 6,707 Feb-22-2021, 06:51 PM
Last Post: eddywinch82

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020