Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidcomfort/f234f4463484c312cf18ecdc271f13d3 to your computer and use it in GitHub Desktop.
Save davidcomfort/f234f4463484c312cf18ecdc271f13d3 to your computer and use it in GitHub Desktop.
# Callback for the Graphs
@app.callback(
Output('paid-search', 'figure'),
[Input('datatable-paid-search', "selected_rows"),
Input('my-date-picker-range-paid-search', 'end_date')])
def update_paid_search(selected_rows, end_date):
travel_product = []
travel_product_list = df[(df['Category'] == 'Paid Search')]['Placement type'].unique().tolist()
for i in selected_rows:
travel_product.append(travel_product_list[i])
# Filter by specific product
filtered_df = df[(df['Placement type'].isin(travel_product))].groupby(['Year', 'Week']).sum()[['Spend TY', 'Spend LY', 'Sessions - TY', 'Sessions - LY', 'Bookings - TY', 'Bookings - LY', 'Revenue - TY', 'Revenue - LY']].reset_index()
fig = update_graph(filtered_df, end_date)
return fig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment