擅长:python、mysql、java
<p>数据以三个步骤形成,因此,我们必须以三个步骤进行迭代,最后在列轴上连接:</p>
<pre><code>pd.concat([df.iloc[n::3].
reset_index(drop=True).
set_index(pd.Index([index]*3),
append = True)
.unstack()
.swaplevel(1,0, axis=1)
for n, index in zip(range(0,df.shape[0]//df.shape[1]),
range(1, df.shape[1] + 1))],
axis = 1)
</code></pre>