如何在集成列时如何将Groupby Pandas对象转换为数据框

发布于 2025-02-01 08:08:57 字数 600 浏览 2 评论 0原文

我想以以下方式将分组的数据帧转换为dataFrame对象:

起点为

“在此处输入图像说明”

整理点是:

“在此处输入图像说明”

重点是将列号集成到category_a category_b

一个人当然可以reset_index并使用循环,通过所有DF获取值并从头开始构造它。但是,这是一个很小的例子,我的数据框架比这更大,我想知道是否有一种更简单的方法可以做到这一点。

谢谢

i would like to transform a grouped dataframe into a dataframe object in the following way:

starting point is

enter image description here

finishing point is:

enter image description here

The point is to integrate the column number into category_a and category_b

one can of course reset_index and with a loop , get the values through all the df and construct it from scratch. however this is a tiny example, and my dataframe is way bigger than that, i was wondering whether there is an easier way to do this.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文