将第1列分组,并用熊猫中第3列的值制作稀疏矩阵

时间:2018-06-27 08:56:32

标签: python pandas pandas-groupby

这是数据帧

short_data1.head()
InvoiceNo     Description                   ratings 

536367 recipeboxwithmetalheart 46.902655

536562 recipeboxwithmetalheart 46.902655

536588 recipeboxwithmetalheart 46.902655

536592 recipeboxwithmetalheart 46.902655

现在我要创建一个稀疏矩阵,其中索引为“ InvoiceNo”,coulmns数组为“描述”值,单元格中的值如果不匹配则为对应的“等级”,然后为0。 基本上,应该告诉我,如果发票中没有该描述,那么如果是,则其值应为与该描述相对应的等级,否则为0

0 个答案:

没有答案