慕仙森
您可以将DataFrame.stack与DataFrame.Transpose一起使用:这是一个例子:import pandas as pddf=pd.DataFrame()df['col1']=[1,2,3,4,5,6]df['col2']=[7,8,9,10,11,12]print(df) col1 col20 1 71 2 82 3 93 4 104 5 115 6 12df2=pd.DataFrame()df2['col1']=[11,12,13,14,15,16,11,12,13,14,15,16]print(df2) col10 111 122 133 144 155 166 117 128 139 1410 1511 16my_stack_df=df.T.stack().reset_index(drop=True)df2['col2']=my_stack_dfprint(df2) col1 col20 11 11 12 22 13 33 14 44 15 55 16 66 11 77 12 88 13 99 14 1010 15 1111 16 12