I have a dataframe of 2 columns: name and id
In the name column I have a couple of duplicates and in the id column I have an empty value for the duplicates of same name.
What I want is to fill that empty value with the value of the first iteration
For example:
df1=pd.DataFrame(columns=["name","id"])
df1["name"]=["a","b","c","a","d","e","b"]
df1["id"]=[1,2,3,"",4,5,""]
name id
0 a 1
1 b 2
2 c 3
3 a
4 d 4
5 e 5
6 b
For the second iteration of "a" and "b" I have an empty value
What I want:
df1["id"]=[1,2,3,1,4,5,2]
How can I fill that empty value with the value of the first iteration ?