I wanted to know if there is a possibility to change the encoding of an element returned by the to_datetime
function of pandas. I need to change to ISO-8859-1 encoding to compare the date with others that are stored in an external file (TXT).
The return of to_datetime
is formatted as follows: 2017-05-22 (YYYY-m-d)
What is stored in the TXT file is as follows: 2017-22-05 (YYYY-d-m)
Note 1: I am loading the TXT files through the read_csv
function of pandas.
Note: I had to set the ISO-8859-1
encoding at the time of loading the files with read_csv, as it was giving error with the default encoding (utf-8, I believe).
formatted date entered by user:
Note: I tried to use the format parameter, but it did not work.
lastDate = pd.to_datetime("2017-05-22")
reading the TXT files:
readingTXT = pd.read_csv(self.fileFolder+file,delimiter="\t",usecols=[0,1,21],encoding="ISO-8859-1",tupleize_cols=True)