问题 I would like to interpolate missing values within groups in dataframe using preceding and following rows value. Here is the df (there are more records within a group but for this example I left 3 per group): import numpy as np import pandas as pd df = pd.DataFrame({'Group': ['a','a','a','b','b','b','c','c','c'],'Yval': [1,np.nan,5,2,np.nan,8,5,np.nan,10],'Xval': [0,3,2,4,5,8,3,1,9],'PTC': [0,1,0,0,1,0,0,1,0]}) df: Group Yval Xval PTC 0 a 1.0 0 0 1 a NaN 3 1 2 a 5.0 2 0 3 b 2.0 4 0 4 b NaN 5 1