是否有一种简单的方法可以在数据框架上进行此转换?
请参阅显示数据框的附件图像。我想以一种结合转置和枢转的方式进行转换。
我可以使用numpy数组和两个循环的进行操作,但是有没有办法使用其他简单选项?
See the attached image showing a DataFrame. I want to transform it in a way that is a combination of transposing and pivoting.
I can do it with NumPy arrays and two for
loops, but is there a way to use other simple options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用了此数据:
然后您可以使用
df. -melt()
,例如,类似:结果:
I used this data:
Then you can achieve this with
df.melt()
, e.g. like so:Result: