I have the following dataframe:
import pandas as pd
df = pd.DataFrame({
'a': [1, 1, 2, 2],
'b': [None, 'w', None, 'z']
})
| a | b |
|---|---|
| 1 | None |
| 1 | 'w' |
| 2 | None |
| 2 | 'z' |
And I want to repeat the values that are not None in column 'b', but based on the value in column 'a'.
At the end I would have this dataframe:
| a | b |
|---|---|
| 1 | 'w' |
| 1 | 'w' |
| 2 | 'z' |
| 2 | 'z' |