solar_file = Path(__file__).parent.parent / "solar_production.csv"
data = pd.read_csv(solar_file, index_col=0)
data['Time'] = pd.to_datetime(data['Time'], errors='coerce')
data = data[pd.notna(data['Time'])]
start_date = data['Time'].min()
end_date = data['Time'].max()
# create a date slidebar to select date range
date_range = st.sidebar.slider('Select Date Range', start_date, end_date, (start_date, end_date))
st.write('You selected:', date_range)
I am not sure what the issue is. Perhaps I should not be calling to_datetime on my pandas dataframe?
Hi! I was having the same issue and the problem turned out to be in the last argument date_range = st.sidebar.slider(‘Select Date Range’, start_date, end_date, (start_date, end_date))
the only accepted format for the value argument is somenthing like that:
(datetime.datetime(2023,1,1), datetime.datetime(2023,7,1))
so I had to do several transformation to get year, month and day of the dates I want to be in the argument “Value”. the result is something like this: