Home > Blockchain >  Finding number of times rows of a particular column are repeated using Pandas
Finding number of times rows of a particular column are repeated using Pandas

Time:12-22

From a given data frame, I need a new data frame that consists only of those rows of a particular column that is repeated three times using Pandas.

For eg. If my Input Dataframe is

Input

then my output data frame should be only of those rows where "NAME" is repeated three times.

Output

CodePudding user response:

Try this:

df = df.groupby('Name').filter(lambda group: group.shape[0] == 3)
  • Related