Hi, @Jacques2101 I understand the problem you are facing with your code:
You are using st.date_input() to obtain date input from the user in the format specified by the format parameter. The issue you’re encountering is related to the data type of the date input.
Pandas Date Indexing: When you perform date-based indexing or calculations in pandas, it expects the index to be in datetime format. Pandas provides various date-related functionalities, and working with datetime objects allows you to perform operations like date subtraction, resampling, and more.
Consistent Datatypes: By converting the user input from st.date_input() to a datetime object using pd.to_datetime(), you ensure that you’re working with a consistent datetime datatype throughout your code. This consistency is essential for reliable date-based operations.
st.date_input returns a date object, whereas pd.to_datetime returns a datetime object (aka Timestamp in pandas). My guess is that your pandas dataframe is indexed using datetimes and not dates.