I have a CSV file which looks something like this
| data_source | destination | description |
|---|---|---|
| A | 1 | A description |
| B | 2 | B description |
| C | 3 | C description |
| A | 3 | A description |
and I'm looking to generate a pivot table that looks something like this
| description | data_source | 1 | 2 | 3 |
|---|---|---|---|---|
| A description | A | x | x | |
| B description | B | x | ||
| C description | C | x |
The closest I've gotten so far is this
table = pd.pivot_table(df, index='data_source', columns='destination', values=['data_source'], aggfunc='first')
I tried using ['description', 'data_source'] as the index to get the description and data_source rows but I end up with a 0 column table. I also don't know the data type for what gets passed to aggfunc to output an 'x' in the valued cells.
I'm new to Pandas and I don't have a good mental model yet so any help is appreciated.