熊猫数据框多级列操作

时间:2018-10-10 21:05:11

标签: pandas

您好,我是一位新的python程序员,尝试与pandas一起工作,我被困在我的一个项目中。我有两个从CSV导入的数据框。 经过一些汇总和连接后,我的表看起来像 enter image description here

然后,我确实在month_year1列上对此表进行了透视:

my_tablep = my_table.pivot_table(index='Product_Name',columns='month_year1')
my_tablep.fillna(0,inplace=True)
my_tablep

结果: enter image description here

但是我想对其进行重组,使其看起来像这样

                        2018-01                           2018-02
Product GRN_Sum Consumed_Sum Stock(GRN-Consumed)       ...............  

0 个答案:

没有答案