Pivoting tables in a pandas dataframe

后端 未结 3 1582
萌比男神i
萌比男神i 2021-01-06 05:11

I have a requirement where in I am trying to count the values and Put them in the pivot table.

This is my dataframe,

  Cola        Colb          
 Ap         


        
3条回答
  •  不思量自难忘°
    2021-01-06 05:44

    IIUC:

    In [178]: d.pivot_table(index='Cola', columns='Colb', aggfunc='size', fill_value=0)
    Out[178]:
    Colb    Rippened  UnRippened
    Cola
    Apple          1           1
    Mango          0           1
    Orange         1           0
    

提交回复
热议问题