I have a dataset using pandas in python and would like to apply an if-then-else rule for a specific column.
If the there is missing value, then replace it with a specific value taken from another column in the same observation, else do nothing.
My dataset is generated by the code as follow:
results = df2.merge(df1,on="sku", how="left")
The column variable that needs to be filled, if empty is "stock_y". If empty, the value of the column variable "stock_x" should be copied to "stock_y". In the case that stock_y is already filled, the code should skip the observation.