I have a table
df = pd.DataFrame({'car': ['toyota', 'toyota', 'ford', 'ford'], 'doors': [nan, 2.0, nan, 4.0], 'seats': [2.0, nan, 4.0, nan]}) that looks like this:
| car | doors | seats |
|---|---|---|
| toyota | NaN | 2 |
| toyota | 2 | NaN |
| ford | NaN | 4 |
| ford | 4 | NaN |
I want to replace NaN with values from rows that match a value from a specific column (i.e car)
I want this:
| car | doors | seats |
|---|---|---|
| toyota | 2 | 2 |
| ford | 4 | 4 |