I'm trying to transform a data frame column containing a 13 digit unix epoch time log into human readable date-time log format.
Here's what I've tried:
alerts[date_time] = alerts['epoch'].map(lambda x: pd.to_datetime(alerts['epoch'], origin='unix', unit = 'ms'))
However, I noticed that all 43 thousand rows of my data frame had the same value despite different epoch time logs. Can someone help?
You are using the wrong syntax of to_datetime
as part of a map.
You simply need to do:
alerts['date_time'] = pd.to_datetime(alerts['epoch'], origin='unix', unit = 'ms')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.