0

I am using python Jupiter notebook. I have a data frame called (transac) that contains a column that has a date called (date) in datatype [int64]

here the date in the int[64]

when I used pd.datetime to change the column to datetime[ns] datatype it is changed, but all the dates are on the same date on 1970-01-01

when changing the date to format of datetime[ns] This is the output

# Change the format of the date from int to date
transac['date']=pd.to_datetime(transac['date'],format='%Y%m%d')

This is the code I used to change the column to DateTime Edit Here is the answer of the question Convert Excel style date with pandas

  • Try first to understand what that codification in the `date`column means and then explain it here so somone can help you decode it. For example, the first two numbers could be related to a day, the next two to a month, and the last number to a year. – Murilo Apr 10 '23 at 12:41

2 Answers2

0

This is because the values in your date column are probably not with a standard encoding. Usually you parse unix epoch time, if your column indeed contains this type of time, the output is correct. If the expected output should be different check the source of your data, so you can find the encoding used for this column.

Oliver
  • 41
  • 7
0

you can use `

import datetime

datetime.date.today()

it's will give you current date

Xavier
  • 11
  • 1