I use the DatePicker on kivymd. I set my program so that when you click the date, it would automatically be save on CSV file I already set. I set so that the date would be save in day/month/year format. But, when I tried to use pandas to accesed the Date Data on my CSV file pd.to_datetime(df_appt['Date']).dt.date
it would give me an error.
ValueError: time data "13/06/2024" doesn't match format "%m/%d/%Y", at position 4.
Even though I already set the date to be save on day/month/year format to CSV file. It only work if I wrote it like this pd.to_datetime(df_appt['Date'], format='%d/%m/%Y').dt.date
Here’s my code :
def on_ok(self, instance_date_picker):
global converted_date_string
date = instance_date_picker.get_date()[0]
date = str(date)
date_object = datetime.strptime(date, "%Y-%m-%d")
converted_date_string = date_object.strftime("%d/%m/%Y")
self.root.ids.selected_date_label.text = f"{converted_date_string}"
instance_date_picker.dismiss()
When I tried using different file and using manual input (not from the date picker), this pd.to_datetime(df_appt['Date']).dt.date
work just fine.
Why I have to set it like this pd.to_datetime(df_appt['Date'], format='%d/%m/%Y').dt.date
while using kivymd date picker even though I already set it to be save as day/month/year format on my CSV file?