I have df:
id number
1 5
1 0
1 0
1 2
2 0
3 1
I want to write a function to fill 0 values.I want for each id(for each group) , when the value in number column is zero, to search the closet non zero value in the column and return the value. for example to id 1 to fill the second and third-row with 2. If I dont have such value like in id 2 , just to remain it as is. How can I do that?