Black Lives Matter. Please consider donating to Black Girls Code today.

Grouping and aggregating data in dash plotly

I would like to create a dash plotly table that will group by the sales system code column and return the sum of all charges associated with a sales system code in a given time period.

I used datepickerrange to allow users to select a start date and end date and followed tried to follow this documentation to get my desired output, however I get this error message when I try to run my dash app locally:

ValueError: Invalid property specified for object of type plotly.graph_objs.Table: 'transforms
...
Traceback (most recent call last)
File "C:\Users\User\Desktop\test.py", line 82, in update_table
                                   performance['Rental Charge']],
                           fill_color='lavender',align='left'),
                transforms=[
                    dict(
                        typ='groupby',
                        groups=performance['SalesSystemCode']

In order to help you replicate the error message here is the code I am using to run my dashboard

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
#html layout
app.layout = html.Div(children=[
    html.H1(children='SAC Challenge Level 2 Dashboard', style={
        'textAlign': 'center',
        'height': '10'
    }),
    html.Div(children='''
        Objective: Studying the impact of supervision on the performance of sales executives in Area 1
        '''),
    dcc.DatePickerRange(
        id='year_month',
        start_date=min(merged_hr['Month'].dt.date.tolist()),
        end_date=max(merged_hr['Month'].dt.date.tolist()),
        calendar_orientation='vertical',
    ),
    dcc.Graph(
        id='performancetable',
    )
])
@app.callback(dash.dependencies.Output('performancetable','figure'),
             [dash.dependencies.Input('year_month', 'start_date'),
              dash.dependencies.Input('year_month', 'end_date')])
def update_table(start_date,end_date):
    performance = merged_hr[(merged_hr['Month'] > start_date) & (merged_hr['Month'] < end_date)]
    return {
        'data': [
            go.Table(
                header=dict(values=list(performance.columns),fill_color='paleturquoise',align='left'),
                cells=dict(values=[performance['Month'],performance['SalesSystemCode'],performance['TITULO'],
                                   performance['HireDate'],performance['MonthsofEmploymentRounded'],performance['SupervisorEmployeeID'],
                                   performance['BASE'],performance['carallowance'],performance['Commission_Target'],
                                   performance['Fulfilment %'], performance['Commission Accrued'],performance['Commission paid'],
                                   performance['Características (D)'],performance['Características (I)'],performance['Características (S)'],
                                   performance['Características (C)'],performance['Motivación (D)'],performance['Motivación (I)'],
                                   performance['Motivación (S)'],performance['Motivación (C)'],performance['Bajo Stress (D)'],
                                   performance['Bajo Stress (I)'],performance['Bajo Stress (S)'],performance['Bajo Stress (C)'],
                                   performance['Rental Charge']],
                           fill_color='lavender',align='left'),
                transforms=[
                    {
                        type: 'aggregate',
                        groups: performance['SalesSystemCode'],
                        aggregation: [
                            {target: 'Rental Charge', func:'sum'}
                            ]
                        }],
        'layout': go.Layout(
            title='Performe',
            paper_bgcolor='black',
            )
        }
if __name__ == '__main__':
        app.run_server(debug=True)

and here is a sample of the data I am using in merged_hr:

{'Month': {0: Timestamp('2017-12-01 00:00:00'),
  1: Timestamp('2017-12-01 00:00:00'),
  2: Timestamp('2017-12-01 00:00:00'),
  3: Timestamp('2017-12-01 00:00:00'),
  4: Timestamp('2017-12-01 00:00:00'),
  5: Timestamp('2017-12-01 00:00:00'),
  6: Timestamp('2017-12-01 00:00:00'),
  7: Timestamp('2017-12-01 00:00:00'),
  8: Timestamp('2017-12-01 00:00:00'),
  9: Timestamp('2017-12-01 00:00:00')},
 'SalesSystemCode': {0: 91868.0,
  1: 91868.0,
  2: 91868.0,
  3: 91868.0,
  4: 91868.0,
  5: 91868.0,
  6: 91868.0,
  7: 91868.0,
  8: 91868.0,
  9: 91868.0},
 'TITULO': {0: 'SALES SUPERVISOR',
  1: 'SALES SUPERVISOR',
  2: 'SALES SUPERVISOR',
  3: 'SALES SUPERVISOR',
  4: 'SALES SUPERVISOR',
  5: 'SALES SUPERVISOR',
  6: 'SALES SUPERVISOR',
  7: 'SALES SUPERVISOR',
  8: 'SALES SUPERVISOR',
  9: 'SALES SUPERVISOR'},
 'BirthDate': {0: Timestamp('1982-11-05 00:00:00'),
  1: Timestamp('1982-11-05 00:00:00'),
  2: Timestamp('1982-11-05 00:00:00'),
  3: Timestamp('1982-11-05 00:00:00'),
  4: Timestamp('1982-11-05 00:00:00'),
  5: Timestamp('1982-11-05 00:00:00'),
  6: Timestamp('1982-11-05 00:00:00'),
  7: Timestamp('1982-11-05 00:00:00'),
  8: Timestamp('1982-11-05 00:00:00'),
  9: Timestamp('1982-11-05 00:00:00')},
 'HireDate': {0: Timestamp('2012-04-23 00:00:00'),
  1: Timestamp('2012-04-23 00:00:00'),
  2: Timestamp('2012-04-23 00:00:00'),
  3: Timestamp('2012-04-23 00:00:00'),
  4: Timestamp('2012-04-23 00:00:00'),
  5: Timestamp('2012-04-23 00:00:00'),
  6: Timestamp('2012-04-23 00:00:00'),
  7: Timestamp('2012-04-23 00:00:00'),
  8: Timestamp('2012-04-23 00:00:00'),
  9: Timestamp('2012-04-23 00:00:00')},
 'SupervisorEmployeeID': {0: 7935,
  1: 7935,
  2: 7935,
  3: 7935,
  4: 7935,
  5: 7935,
  6: 7935,
  7: 7935,
  8: 7935,
  9: 7935},
 'BASE': {0: 895,
  1: 895,
  2: 895,
  3: 895,
  4: 895,
  5: 895,
  6: 895,
  7: 895,
  8: 895,
  9: 895},
 'carallowance': {0: 350,
  1: 350,
  2: 350,
  3: 350,
  4: 350,
  5: 350,
  6: 350,
  7: 350,
  8: 350,
  9: 350},
 'Commission_Target': {0: 708.33,
  1: 708.33,
  2: 708.33,
  3: 708.33,
  4: 708.33,
  5: 708.33,
  6: 708.33,
  7: 708.33,
  8: 708.33,
  9: 708.33},
 'Area': {0: 'Area 1',
  1: 'Area 1',
  2: 'Area 1',
  3: 'Area 1',
  4: 'Area 1',
  5: 'Area 1',
  6: 'Area 1',
  7: 'Area 1',
  8: 'Area 1',
  9: 'Area 1'},
 'Fulfilment %': {0: 1.0248618784530388,
  1: 1.0248618784530388,
  2: 1.0248618784530388,
  3: 1.0248618784530388,
  4: 1.0248618784530388,
  5: 1.0248618784530388,
  6: 1.0248618784530388,
  7: 1.0248618784530388,
  8: 1.0248618784530388,
  9: 1.0248618784530388},
 'Commission Accrued': {0: 708.33,
  1: 708.33,
  2: 708.33,
  3: 708.33,
  4: 708.33,
  5: 708.33,
  6: 708.33,
  7: 708.33,
  8: 708.33,
  9: 708.33},
 'Commission paid': {0: 1361.99,
  1: 1361.99,
  2: 1361.99,
  3: 1361.99,
  4: 1361.99,
  5: 1361.99,
  6: 1361.99,
  7: 1361.99,
  8: 1361.99,
  9: 1361.99},
 'Características (D)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Características (I)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Características (S)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Características (C)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Motivación (D)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Motivación (I)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Motivación (S)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Motivación (C)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Bajo Stress (D)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Bajo Stress (I)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Bajo Stress (S)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Bajo Stress (C)': {0: nan,
  1: nan,
  2: nan,
  3: nan,
  4: nan,
  5: nan,
  6: nan,
  7: nan,
  8: nan,
  9: nan},
 'Report month': {0: Timestamp('2017-07-01 00:00:00'),
  1: Timestamp('2017-07-01 00:00:00'),
  2: Timestamp('2017-07-01 00:00:00'),
  3: Timestamp('2017-07-01 00:00:00'),
  4: Timestamp('2017-07-01 00:00:00'),
  5: Timestamp('2017-07-01 00:00:00'),
  6: Timestamp('2017-07-01 00:00:00'),
  7: Timestamp('2017-07-01 00:00:00'),
  8: Timestamp('2017-09-01 00:00:00'),
  9: Timestamp('2017-09-01 00:00:00')},
 'Rental Charge': {0: 30.0,
  1: 24.95,
  2: 30.0,
  3: 22.5,
  4: 18.7125,
  5: 10.99,
  6: 6.25,
  7: 3.75,
  8: 22.5,
  9: 6.0},
 'ID Vendedor': {0: 91868.0,
  1: 91868.0,
  2: 91868.0,
  3: 91868.0,
  4: 91868.0,
  5: 91868.0,
  6: 91868.0,
  7: 91868.0,
  8: 91868.0,
  9: 91868.0},
 'MonthsofEmploymentRounded': {0: 67.0,
  1: 67.0,
  2: 67.0,
  3: 67.0,
  4: 67.0,
  5: 67.0,
  6: 67.0,
  7: 67.0,
  8: 67.0,
  9: 67.0}}