如果索引中只有year并且month级别使用列表理解并更改连接字符串的格式:#python 3df.index = pd.to_datetime([f'{a}-{b}-01' for a, b in df.index])#python 2df.index = pd.to_datetime(['{}-{}-01'.format(a, b) for a, b in df.index])如果还有天:#python 3df.index = pd.to_datetime([f'{a}-{b}-{c}' for a, b, c in df.index])#python 2df.index = pd.to_datetime(['{}-{}-{}'.format(a, b, c) for a, b, c in df.index])进而:df1 = df.resample('D').ffill()