I have a hopefully straightforward question that has been giving me a lot of difficulty for the last 3 hours. It should be easy.
Here's the challenge.
I have a pandas dataframe:
+--------------------------+
| Col 'X' Col 'Y' |
+--------------------------+
| class 1 cat 1 |
| class 2 cat 1 |
| class 3 cat 2 |
| class 2 cat 3 |
+--------------------------+
What I am looking to transform the dataframe into:
+------------------------------------------+
| cat 1 cat 2 cat 3 |
+------------------------------------------+
| class 1 1 0 0 |
| class 2 1 0 1 |
| class 3 0 1 0 |
+------------------------------------------+
Where the values are value counts. Anybody have any insight? Thanks!