熊猫数据框添加列并缩小行

时间:2018-07-02 14:15:59

标签: python pandas

我有一个格式的数据框

    category       week  items_sold business_use            nmv  \
0  Appliances  WEEK 22            57    marketing   15397.740000   
1  Appliances  WEEK 22           391        other   99970.030000   
2  Appliances  WEEK 23           135    marketing   29612.957727   
3  Appliances  WEEK 23          1157        other  259684.447076   
4  Appliances  WEEK 24            63    marketing   15464.071443

我想按2合并2行:

  • 删除col business_use
  • 创建col items_sold_marketing,nmv_marketing

有什么想法吗?

0 个答案:

没有答案