Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with datatime
#1
Hello i am beginner with python and i have one problem with datetime in my script.
This is my data set
DATE_y
13.10.2017
19.7.2018
12.10.2018
9.4.2019

DATA['DATE_y2']=pd.to_datetime(DATA['DATE_y'])

This is results
row DATE_y2 DATE_y
1 13.10.2017 13.10.2017
2 19.7.2018 19.7.2018
3 10.12.2018 12.10.2018
4 4.9.2019 9.4.2019

Can you help with with the results? Why is problem in row 3 and 4 ? and row 1 row 2 are correct.
Does anyone know where is the problem?

Thank you so much for your answer.
Reply
#2
Check the dayfirst argument in the docs:
https://pandas.pydata.org/pandas-docs/st...etime.html

I'm pretty sure your problem is due to the fact that in America we do dates like MM-DD-YYYY whereas the rest of the world does the more logical DD-MM-YYYY. Of course we should all be using the best choice which is YYYY-MM-DD but what are you gonna do?
"So, brave knights, if you do doubt your courage or your strength, come no further, for death awaits you all with nasty, big, pointy teeth!" - Tim the Enchanter
Reply
#3
I checked it. The dayfirst was problem. I repaired it . Thank you so much.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020