I have a 3 column dataframe. Let's say my columns are "doc", "word", "count" and each row shows number of occurrences of a word in a document.
| doc | word | count |
+-----+------+-------+
| 0 | 0 | 10 |
| 0 | 7 | 2 |
| 0 | 4 | 5 |
| 1 | 2 | 5 |
+-----+------+-------+
I want to convert this dataframe to a matrix having rows as documents and columns as words so I do the following:
matrix = pd.pivot_table(my_df, index="doc", columns="word", values="count", fill_value=0)
What I get is a matrix having columns [0,2,4,7]. However, what I want is to have another range for my columns, e.g. range(10): [0,1,2,3,4,5,6,7,8,9]. This latter will end up some columns having all entries as 0 and this is what I want.
How can I achieve this?