Let me write a dataframe for explaining my question:
Loc Length Size
A 5 50
A 10 90
A 8 0
B 20 140
B 5 50
B 12 0
Consider I have a dataframe like this. What I want to do is replacing Size values which are equals 0. I want to replace this values like: If the size in Loc A, what I want to do is (sum of sizes in A) / (sum of lengths in A) multiple by Length and change zero this value. I want to do this on every Size values which equals 0, and it is depending on his Location's sumSize/sumLength and his row's Length value. I tried but I couldn't do anything. Please help me about this, thanks!