小编fgs*_*fgs的帖子

将多索引数据帧拆散到pandas中的平面数据框

我在pandas中有一个名为groupt3的多索引df,当我输入groupt3.head()时,它看起来像这样:

                datetime     song   sum   rat
artist datetime
2562     8      2            2      26    0
         46     19           19     26    0
         47     3            3      26    0
4Hero    1      2            2      32    0
         26     20           20     32    0
         9      10           10     32    0
Run Code Online (Sandbox Code Playgroud)

我希望有一个"平坦"的数据框,它采用艺术家索引和日期时间索引并"重复它"来形成:

artist     date time    song   sum   rat
2562       8            2      26    0
2562       46           19     26    0
2562       47           3      26    0
Run Code Online (Sandbox Code Playgroud)

等等...

谢谢.

python ipython pandas

5
推荐指数
2
解决办法
4742
查看次数

标签 统计

ipython ×1

pandas ×1

python ×1