Supposing I have the following DataFrame df
df = pd.DataFrame({
"a" : [8,8,0,8,8,8,8,8,8,8,4,1,4,4,4,4,4,4,4,4,4,4,7,7,4,4,4,4,4,4,4,4,5,5,5,5,5,5,1,1,5,5,5,5,5,5,1,5,1,5,5,5,5]}
i want to normalize my data, if there is consecutive value less than 3 times, changes the value with neighboring consecutive value.
result:
df = pd.DataFrame({
"a" : [8,8,8,8,8,8,8,8,8,8,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]}
currently i make this work by iterate manually, and i think pandas has special function to do it.