要有Datetime形式的索引
So 首先要将时间转化为datetime的形式
Then 设为索引
Final 重采样就好
年—A
月周天—M/W/D
分钟—T
秒—S
path1=r'D:\Fluxnet\try'
path2=r'D:\Fluxnet\try_ndvi'
for i,j in zip(os.listdir(path1),os.listdir(path2)):
sole_i=pd.read_csv(os.path.join(path1,i))
sole_j=pd.read_csv(os.path.join(path2,j))
sole_i['TIMESTAMP_START']=sole_i['TIMESTAMP_START'].astype('str')
sole_i['TIMESTAMP_START']=pd.to_datetime(sole_i['TIMESTAMP_START'])
sole_j=sole_j[['TIMESTAMP_START','NDVI']]
sole_j['TIMESTAMP_START'] = pd.to_datetime(sole_j['TIMESTAMP_START'])
sole_j = sole_j.set_index('TIMESTAMP_START')
sole_j = sole_j.resample('1D').interpolate() # 30T 按分钟插值 1D按天插值
sole_j = sole_j.reset_index()
sole=pd.merge(sole_i, sole_j,how='left',on='TIMESTAMP_START')
sole['NDVI']=sole['NDVI'].interpolate(method='pad') # 16天一个值