I have a pandas df like this (a small sample):
| time | name | val1 | val2 | 
|---|---|---|---|
| 0500 | unit1 | 1 | nan | 
| 0500 | unit1 | nan | 1 | 
| 0500 | unit1 | 1 | 1 | 
| 0500 | unit2 | 1 | nan | 
| 0500 | unit3 | 1 | nan | 
| 0500 | unit3 | nan | 1 | 
| 0500 | unit3 | 1 | 1 | 
What I want is this:
| time | name | val1 | val2 | 
|---|---|---|---|
| 0500 | unit1 | 1 | 1 | 
| 0500 | unit2 | 1 | nan | 
| 0500 | unit3 | 1 | 1 | 
I have a list of duplicate values,
duplicates = ['unit1', 'unit3']
What I attempted is this:
for unit in duplicates:
        temp_df = df.loc[df['name'] == unit].dropna()
        update_df = update_df.append(temp_df)
but as I iterate, it's appending the dropped nan values back into the data-frame for other duplicate units. How else can I do this with a data-frame? Thank you.