I have a dataset that looks like (with more columns and rows):
id type value
0 104 0 7999
1 105 1 196193579
2 108 0 245744
3 NaN 1 NaN
Some rows have NaN values, and I already have the indexes for these rows. Now I would like to concat these rows with their previous row, except for NaN values. If I say indexes=[3]
, then the new dataframe should be:
id type value
0 104 0 7999
1 105 1 196193579
2 108 01 245744
How can I do this?
NOTE: First row never will be in the list of indexes I have. The solution must be given my list of indexes. I also know the names of the columns where NaN values are, if necessary.