Hi there , I have a data frame which contains date format like this('01-january-2016 to 01-august-2018) ,the interval is one month , I want a date range slider I have tried it but don’t know where I am wrong ,below is my code
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
I am not 100% sure how pandas are handling dates but:
It looks like your dates are in a string format and you are asking for the minimum and maximum value of these which does not make any sense. Asking for the maximum in a list of strings is like asking a book for its maximum word.
You need to convert your dates into some kind of number (try and look up pythons Datetime library), sort it, then convert it back again to strings.
I was just having a similar problem, and was going to post if anyone knows the answer.
I think there could be two problems.
One problem as mentioned by Blaceus, is that your datetimes are not being imported as datetimes. There’s a parsedates argument in read_csv you can try. Also you could try saving your data as a feather file, which will preserve the datetime format.
The other problem I think is that the rangeslider and slider components don’t support datetime formats. But I’m not 100% sure about this. I tested it and couldn’t get it working with datetime formats, but who knows, maybe I was doing something wrong.
You might have to index your data with just plain numbers.
There’s also this post here, but it wasn’t super clear the answer which solved it.