尝试使用python中的熊猫复制sumifs
I have a dataframe that is essentially this:
And I'd like an output that's like this
Where it extends until the last period.
Is anyone sure how to do this using python/pandas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
索引
设置为“位置”和“资产”,并在所有期间列上使用stack
,这将为您提供所需的结构。然后是
groupby.sum()
的问题:打印:
You could set your
index
to be "Location" and "Asset" and usestack
on all the Period columns which would get you the structure you are looking for.Then it's a matter of
groupby.sum()
:prints: