慕的地8271018
使用merge_asof:df = pd.merge_asof(df1, df2, left_index=True, right_index=True, tolerance=pd.Timedelta(24, 'H'), direction='forward')print (df) A B2019-12-02 1.000000 NaN2019-12-04 1.020100 A2019-12-05 1.030301 B2019-12-06 1.040604 NaN2019-12-09 1.051010 NaN2019-12-10 1.061520 Ddf = pd.merge_asof(df1, df2, left_index=True, right_index=True, tolerance=pd.Timedelta(25, 'H'), direction='forward')print (df) A B2019-12-02 1.000000 NaN2019-12-04 1.020100 A2019-12-05 1.030301 B2019-12-06 1.040604 C2019-12-09 1.051010 NaN2019-12-10 1.061520 D