Trouble understanding how callbacks work with dataframes

Hello,

I’m new to dash and I understand the graphing aspect but I’m having a hard time comprehending the creation of callbacks. I’m using a data frame but I keep receiving a key error ‘Month’. However, that data frame key is, in fact, part of the data frame. I’m trying to create a simple paycheck graph that has a weekly radio button which would populate each bar as a weekly sum of my pay and a monthly radio button that would populate each bar as my monthly sum of pay. Attached is a snip-it of code. Any help on this matter would be greatly appreciated. I haven’t come across any examples that use radio buttons and data frames.

df_monthly = df_paystub.groupby(['Month']).sum()

dcc.RadioItems(
            id='data-view',
            options=[
                {'label': 'Weekly', 'value': 'Weekly'},
                {'label': 'Monthly', 'value': 'Monthly'},
            ],
            value='Weekly',
            labelStyle={'display': 'inline-block'}
        ),

dcc.Graph(
                id='pay',
            )

@app.callback(dash.dependencies.Output('pay', 'figure'),
              [dash.dependencies.Input('data-view', 'value')])

def update_fig():
    figure={
        'data': [
            go.Bar(
                x = df_monthly['Month'],
                y = df_monthly['CheckTotal'],
                name = 'Take Home Pay',
            ),
                go.Bar(
                x = df_monthly['Month'],
                y = df_monthly['EarnTotal'],
                name = 'Earnings',
            )
        ],
        'layout': go.Layout(
            title = 'Take Home Pay vs. Earnings',
            barmode = 'group',
            yaxis = dict(title = 'Pay (U.S. Dollars)'),
            xaxis = dict(title = 'Date Paid')
        )
    }
    return {'data': [figure]}