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

Rangeslider callback with df.column slicing

Hi guys,

I am currently building an app which uses a dcc.Rangeslider components which marks which represent months and i intend to be able to slice by data based on this but the Rangslider gives me some issues for concern.

Any help will be appreciated.Below is my code:

dcc.Rangeslider(
id=‘Rangeslider’,
min=Month_index[0],
max=Month_index[-1],
marks=dict(zip(Month_index,Month_name),
value=[Month_index[0],Month_index[-1],

I am using a dataframe whose columns happen to be my datetime values so i will be slicing my data on the columns using .loc[:,start:end] my callback

@app.callback Out(‘count’,'children),[Input(‘gender’,‘value’),Input(‘Rangeslider’,'value)])
def set_count(gender,rangeslider):
df=df.loc[:,str(Rangeslider[0],str(Rangeslider[1]]
return df.loc[str(gender)].sum()

Can someone please explain to me why the call back doesnt work.

Hi @Jason4
can you please put your code into preformatted text and share the dataframe/.csv file with us (or an example of a few rows and columns). It would be easier to help if I could play around with it a little.