replace rarely occurring values in a pandas dataframe,g = df.groupby('column_name')