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

后端 未结 4 1781
别那么骄傲
别那么骄傲 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:48

    You can do this as a post processing step using to_datetime and passing arg unit='ms':

    In [5]:
    df['UNIXTIME'] = pd.to_datetime(df['UNIXTIME'], unit='ms')
    df
    
    Out[5]:
       RUN                UNIXTIME  VALUE
    0    1 2015-11-10 13:05:02.320     10
    1    2 2015-11-10 13:05:02.364     20
    2    3 2015-11-10 13:05:22.364     42
    

提交回复
热议问题