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
then my output data frame should be only of those rows where "NAME" is repeated three times.
CodePudding user response:
Try this:
df = df.groupby('Name').filter(lambda group: group.shape[0] == 3)