Hello guys, I tried to deploy a custom slider in my streamlit app and what happens is very strange, the slider works with dates after 1st of February 1970, but when an older date is passed it gives the following error:
The code of the properly working slider bar is (note: gp.m2_usa is a DataFrame imported from other file)
format = 'MMM DD, YYYY' # format output
start_date = gp.m2_usa.index[132].date() #Here the start date is 1970-02-01
end_date = gp.m2_usa.index[-1].date() #Here the end date is 2021-06-01
slider = st.slider('Select date', min_value=start_date, value=end_date, max_value=end_date, format=format)
Here the slider works properly
But if I choose just one older index as in this code:
format = 'MMM DD, YYYY' # format output
start_date = gp.m2_usa.index[131].date() #Here the start date is 1970-01-01
end_date = gp.m2_usa.index[-1].date() #Here the end date is 2021-06-01
slider = st.slider('Select date', min_value=start_date, value=end_date, max_value=end_date, format=format)
It raises the following error:
Thank you in advance for all your help!
1 Like
Hi @beautiful_blood
Something seems to be wrong with your min_value
variable.
Can you please share the related code, so I can try to debug on my machine?
Thanks
Charly
1 Like
First of all thank you very much for your help!
I uploaded the code with the mistake to my repo in order you maybe can clone it and make a quicker debug!
Please, find it here: https://github.com/Serrat96/moneyprintersgobrr
1 Like
Iāve been investigating and as far as I can see the problem is the conversion from āhuman dateā to āepoch timestampā. It seems that in 1970-01-01 00:00:00 the conversion to āepoch timestampā returns zero:
And for older dates returns negative values. It seems that the conversor is unable (I donāt know for what reason) to work with zero or negative values of āepoch timestampā. If for example i go back one day the time is negative as you can see in this picture:
I will keep investigating. I donāt know whatās āepoch timestampā and whatās the problem with it being zero or negative.
Hope we can find a solution soon!
1 Like
Ok. As far as I can see Windows is unable to work with zero or negative āepoch timestampā. The only thing I can think of is, as I see you @Charly_Wargnier are Streamlit staff is to contact with Streamlit developers in order to make the necessary changes to avoid the slider working with that āepoch timestampā time formatā¦
In other operative systems as Mac or Linux, the OS is capable to work with that negative āepoch timestampā but it seems Windows canātā¦
Maybe thereās another easier and simple solution, but at the moment this is the conclusion I got. In case the Streamlit team has a better solution I would be very pleased of implement it.
Thank you very much for all your time. At the moment, instead of the slider, I will make a date selector with st.date_input as it seems has no problem working with older than 1970-01-01 dates.
1 Like
Thanks @beautiful_blood
Iāll share with Devs now.
Best,
Charly
1 Like
Thank you for all your time and interest in the issue!
Hope to hear from you the developerās response if possible!
Best wishes for all of you!
1 Like
Hello @Charly_Wargnier just FYI, I tried the code on a MacBook and it works perfectly. So a 100% itās a Windows problem.
Thank you very much for all your time and attention!
1 Like
Youāre very welcome!
Glad you managed to make it work by switching platform.
Happy Streamlitinā!
Best,
Charly