Jan-19-2019, 09:19 AM
I have below DataFrame,
Rows are number from 0,1,...n (follow the python notation)
Case1: For 1st column, 2rd row id empty and the average of row1~row2 is 1.25
case2: column1, row6 is empty, and fill with the average calculated from row3~row5.
Case3:Row9 in column1 is empty, and filled with the average calculated using row7&row8
Same rule follow in the column2. I am new to Python, I only knew pd.drop function to drop the row meet the criterion.Please kindly some one help how to do to replace the empty row with mean.
Desired output:
1.0 2.1 1.5 0.9 4.8 1.7 9.0 2.0 1.0 8.7 2.9 1.8 1.1 0.6 2.0 3.2I want to replace empty cells with mean uptnes the empty row, and in the next empty row, again take the mean of of the row after last empty row. For example
Rows are number from 0,1,...n (follow the python notation)
Case1: For 1st column, 2rd row id empty and the average of row1~row2 is 1.25
case2: column1, row6 is empty, and fill with the average calculated from row3~row5.
Case3:Row9 in column1 is empty, and filled with the average calculated using row7&row8
Same rule follow in the column2. I am new to Python, I only knew pd.drop function to drop the row meet the criterion.Please kindly some one help how to do to replace the empty row with mean.
Desired output:
1.00 2.10 1.50 2.10 1.25 0.90 4.80 0.90 1.70 9.00 2.00 1.00 2.80 5.00 8.70 2.90 1.80 1.10 5.25 0.60 2.00 3.20