I have a time series data with a column of a multiclass object, I would like to convert the object happening in less than two instances to the nearest bigger group. Here is an example of the data frame. I wish to convert 'No' appears at the 4th row to 'Yes' and similarly, 'Yes' in the 16th to 'No'.
df = pd.DataFrame(data = {'A': ['Yes', 'Yes', 'Yes', 'No', 'Yes', 'Yes', 'Probable',
'Probable', 'Probable', 'Yes', 'Yes', 'Yes',
'No', 'No','No', 'Yes', 'No','No'],
'Counter': [1, 2, 3, 1, 1, 2, 1, 2, 3, 1, 2, 3, 1, 2,
3, 1, 1, 2]})
Does anyone could help me to define a loop or function? Thank you in advance.