I have a Pandas dataframe built like:
| Col1 | Col2 |
|---|---|
| 1 | A |
| 1 | B |
| 1 | B |
| 2 | A |
| 2 | A |
| 3 | A |
| 3 | Nan |
For every value of Col1, I want to count every value of Col2 ignoring the Nan values and put the sum in the associated column, obtaining something like:
| Col1 | A | B |
|---|---|---|
| 1 | 1 | 2 |
| 2 | 2 | 0 |
| 3 | 1 | 0 |
How can I do that in Pandas? I have a lot of values in Col1 and lots of columns like Col2. Thank you very much!