To convert the date '01-11-2017' to datetime format using pd.to_datetime() in Python, you can specify the format of the input date using the format parameter. In this case, the format of the input date is 'dd-mm-yyyy'.
Here is an example of how to convert the date using pd.to_datetime():
main.py125 chars7 lines
The %d represents the day, %m represents the month, and %Y represents the four-digit year in the format. By specifying the format parameter as '%d-%m-%Y', the pd.to_datetime() function will correctly parse the date string and convert it to a datetime object.
Output:
main.py20 chars2 lines
Now, datetime_obj contains the converted datetime object.
gistlibby LogSnag