问题
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     211
06-JAN-17    105     NaN
07-JAN-17    104     NaN
What is the best way, to fill the missing values, using last available ones?
Following is the intended result:
              A       B 
  zDate
01-JAN-17    100     200
02-JAN-17    111     203
03-JAN-17    111     202
04-JAN-17    109     205
05-JAN-17    101     211
06-JAN-17    105     211
07-JAN-17    104     211
    回答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
    来源:https://stackoverflow.com/questions/45320928/pandas-fill-missing-values-using-last-available