I can't seem to figure out how to ask this question in a searchable way, but I feel like this is a simple question.
Given a pandas Dataframe object, I would like to use one column as the index, one column as the columns, and a third column as the values.
For example:
a b c
0 1 dog 2
1 1 cat 1
2 1 rat 6
3 2 cat 2
4 3 dog 1
5 3 cat 4
I would like to user column 'a' as my index values, column 'b' as my columns, and column 'c' as the values for each row/column and fill with 0 for missing values (if possible). For example...
dog cat rat
1 2 1 6
2 0 2 0
3 1 4 0
This would be an 'a' by 'b' matrix with 'c' as the filling values
pivot_table. See the docs on "reshaping and pivot tables".pivot_table, but an interesting method) and "dataframe.reindex" methods