Pandas: Fill Missing Values Using Last Available
I have a dataframe as follows: A B zDate 01-JAN-17 100 200 02-JAN-17 111 203 03-JAN-17 NaN 202 04-JAN-17 109 205 05-JAN-17 101
Solution 1:
Use ffill
function, what is same as fillna
with method ffill
:
df = df.ffill()
print (df)
A B
zDate
01-JAN-17 100.0 200.0
02-JAN-17 111.0 203.0
03-JAN-17 111.0 202.0
04-JAN-17 109.0 205.0
05-JAN-17 101.0 211.0
06-JAN-17 105.0 211.0
07-JAN-17 104.0 211.0
Post a Comment for "Pandas: Fill Missing Values Using Last Available"