I am trying to add a pivot table in excel using python script with pandas but not able to do so. I won't to count number of missed and met entries for each priority.
Excel script:
import pandas as pd
df = pd.DataFrame({'Priority': ['p1','p2','p3','p2','p3'],'SLA': ['Met','Missed','Missed','Met','Missed']})
Excel data:
| Priority | SLA |
|---|---|
| p1 | Met |
| p2 | Missed |
| p3 | Missed |
| p2 | Missed |
| p3 | Missed |
desired output:
| Priority | Met | Missed |
|---|---|---|
| p1 | 1 | 0 |
| p2 | 1 | 1 |
| p3 | 0 | 2 |
I tried different combination\approach with
table = pd.pivot_table(df,index='Priority',columns=['SLA'])
but couldn't get it right. I am struggling hard for this. I am trying this first time.