有许多用于重新排列表格型数据的基础运算。这些函数也称作重塑(reshape)或轴向旋转(pivot)运算

重塑层次化索引

层次化索引为DataFrame数据的重排任务提供了一致性方式。

stack : 将数据的列旋转为行

unstack: 将数据的行旋转为列

看例子:

data = DataFrame(np.arange(6).reshape((2, 3)), index=pd.Index(['Ohio', 'Colorado'], name='state'), columns=pd.Index(["one", "two", "three"], name="number"))
View Code

相关文章:

  • 2021-12-29
  • 2021-06-20
  • 2021-09-27
  • 2021-04-28
  • 2021-09-18
  • 2021-10-25
  • 2021-05-13
  • 2022-01-25
猜你喜欢
  • 2021-12-01
  • 2019-01-18
  • 2021-10-24
  • 2021-09-01
  • 2021-12-11
相关资源
相似解决方案