iterate through rows and check if nan pandas code example Example: pandas if nan, then the row above df.fillna(method='ffill')