这是
wide_to_long
pd.wide_to_long(df,['t','l'],i=['id1','id2'],j='drop').reset_index(level=[0,1])Out[52]: id1 id2 t ldrop 1 1 2 a b2 1 2 c d1 3 4 g h2 3 4 i j

这是
wide_to_long
pd.wide_to_long(df,['t','l'],i=['id1','id2'],j='drop').reset_index(level=[0,1])Out[52]: id1 id2 t ldrop 1 1 2 a b2 1 2 c d1 3 4 g h2 3 4 i j