Pandas converting row with unix timestamp (in milliseconds) to datetime

后端 未结 4 1783
别那么骄傲
别那么骄傲 2020-12-08 07:24

I need to process a huge amount of CSV files where the time stamp is always a string representing the unix timestamp in milliseconds. I could not find a method yet to modify

4条回答
  •  悲哀的现实
    2020-12-08 07:36

    I came up with a solution I guess:

    convert = lambda x: datetime.datetime.fromtimestamp(float(x) / 1e3)
    
    df = pd.read_csv(StringIO(data), parse_dates=['UNIXTIME'], date_parser=convert)
    

    I'm still not sure if this is the best one though.

提交回复
热议问题