import pandas as pd# 长格式数据 df_long = pd.DataFrame({'id': ['A', 'A', 'B', 'B', 'C', 'C'],'year': [2020, 2021, 2020, 2021, 2020, 2021],'value': [10, 15, 20, 25, 30, 35] })print(df_long) df_wide = df_long.pivot(index='id', columns='year', values='value') print(df_wide)