1
wondered if there is the possibility to change the encoding of an element returned by the function to_datetime
pandas. I need to switch 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 function read_csv
pandas.
Obs 2.: I needed to define the encoding ISO-8859-1
at the time of loading the files with read_csv, because it was giving error with the standard encoding (utf-8, I believe).
formatting the date entered by the user:
Obs.: I tried using the format parameter, but no effect.
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)
Have you tried comparing:
data1.isoformat()==data2.isoformat()
? or convert the two dates into tuples and compare the elements? The idea would be that you put something else in the question, part of the file, for example or how the user makes the inclusion.– Sidon
Managed to resolve that issue?
– Daniel