I have a panda dataframe which has the following columns, year
, month
, source
and some other field. I would like to group by year
, month
and source
I want the `source`` to appear as a column, after groupby.
source1, source2, source3,....
2017, jan
2017, feb
...
This is how my code looks like
df.pivot_table(index = ['year','month'], columns = 'source', aggfunc = np.size, fill_value = 0)
but I'm getting the following error message
Reindexing only valid wit uniquely valued index objects