My data looks smth like:
| Index | Job | Y | Balance |
|---|---|---|---|
| 1 | A | Yes | 1 |
| 2 | B | No | 2 |
| 3 | A | No | 5 |
| 4 | A | No | 0 |
| 5 | B | Yes | 4 |
I want to summarize the data in the following format, with job in the row and Y in the column:
| Yes | No | |
|---|---|---|
| A | 1 | 2 |
| B | 1 | 1 |
I have tried the following code:
pivot = df.pivot_table(index =['job'], columns = ['y'], values = ['balance'], aggfunc ='count')
I am not able to run the pivot without using balance in the value parameter. How do I get the above result?