I have a dataframe that looks like this:
df = pd.DataFrame({'publisher': ['facebook', 'facebook', 'facebook', 'google', 'google', 'google'],
'month_leadgen': ['2019-01', '2019-02', '2019-03', '2019-01', '2019-02', '2019-03'],
'month_payment': ['2019-01', '2019-02', '2019-03', '2019-01', '2019-02', '2019-03'],
'revenue': [60, 150, 450, 85, 250, 150]})
I then created a pivot table:
df = df.pivot_table(index=['publisher', 'month_leadgen'], columns='month_payment', values='revenue').reset_index()
I am trying to select the column df['2020-01'] but I am receiving an error message:
KeyError: '2020-01'
Can you help me understand why I cannot select this column? The df doesn't seem to be multi indexed. I cannot select any of the month columns but 'month_payment', 'campaign_name', and 'month_leadgen' can be selected no problem.