根据上一行向新列添加数据

时间:2020-08-11 11:56:55

标签: python pandas dataframe

df
     type  content
1    task   buy xbox
2    task   buy fruit from supermarket
3    note   orange with squash\buy if cheap
4    note   apple
5    task   buy sunglassess

注释指的是直接在其上方的任务。如何操作df以获取以下df? 预期输出:

         task                       comment1             comment2
1     buy xbox
2     buy fruit from supermarket   orange with squash     apple
                                   buy if cheap
3     buy sunglassess
...

1 个答案:

答案 0 :(得分:1)

使用助手 private fun openPDFFile() { val intent = Intent("android.intent.action.GET_CONTENT") intent.type = "application/pdf" startActivityForResult(intent, OPERATION_CHOOSE_PDF) } 通过将值与累积总和进行比较来按Series获取组,按GroupBy.cumcount获取计数器,并按DataFrame.set_indexSeries.unstack进行整形:< / p>

task
相关问题