RangeSlider issue with DataFrames

I wanted to check here first before making an issue on Github.

When using a df with the RangeSlider component. I get weird behavior on the slider and a None value as the Output.

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd

app = dash.Dash()

df = pd.DataFrame([-2,-1,0,1,2,3,4,5,6])

app.layout = html.Div([
    html.Div([
        dcc.RangeSlider(
            id='slider',
            min=df.min(),
            max=df.max(),
            value=[-1, 4],
            step=None,
            marks={str(i):i for i in df[0].unique()}
        )
    ],style={'width': '50%', 'margin-top':50, 'margin-bottom':50}
    ),
    html.Div(id='slider-output', style={'margin-top': 20})
])

@app.callback(
    Output('slider-output', 'children'),
    [Input('slider', 'value')])
def multiply(value):
    return 'You have selected "{}"'.format(value)

if __name__ == '__main__':
    app.run_server(debug=True)

Is there another way to approach this using dataframes?

Thanks

I had a quick play around with this, seems that you can’t pass np.int64 and you need to pass pure python integers.

This worked fine for me:

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd

app = dash.Dash()

df = pd.DataFrame([-2,-1,0,1,2,3,4,5,6])

app.layout = html.Div([
    html.Div([
        dcc.RangeSlider(
                id='slider',
                min=int(df.min()),
                max=int(df.max()),
                value=[-1, 4],
                step=None,
                marks={int(i):str(i) for i in df[0].unique()}
                )
        ],style={'width': '50%', 'margin-top':50, 'margin-bottom':50}
            ),
    html.Div(id='slider-output', style={'margin-top': 20})
    ])

@app.callback(
        Output('slider-output', 'children'),
        [Input('slider', 'value')])
def multiply(value):
    return 'You have selected "{}"'.format(value)


if __name__ == '__main__':
    app.run_server()

Ok, so I think this is the same issue already on Github then. Thanks for the example, works fine for me as well.

Thanks again!