I have a dataset where I want to fill the columns and rows in python as shown below:
Dataset:
| P | Q |
|678|1420|
|678|---|
|609|---|
|583|1260|
|---|1260|
|---|1261|
|---|1262|
|584|1263|
|---|403|
|---|---|
Expected Result:
| P | Q |
|678|1420|
|678|1420|
|609|---|
|583|1260|
|583|1260|
|583|1261|
|583|1262|
|584|1263|
|584|403|
|584|403|
I have filled the column P using fillna() but cannot do the same for column Q since the values needs to be filled for key pair.
can someone please help.
With your shown samples, please try following.
Output will be as follows:
ffill documentation