[pandas_timestamps] conversion from str unxtime to timestamps #timestamp #convert #datetime
import sys
from io import StringIO
data = 'RUN,UNIXTIME,VALUE\n1,1447160702320,10\n2,1447160702364,20\n3,1447160722364,42'
df = pd.read_csv(StringIO(data))
#this converts unix times 1447160702320 to datetime with ms
df['UNIXTIME'] = pd.to_datetime(df['UNIXTIME'], unit='ms')
## relevant example from vt
# timestamps could be with .decimal part
data='acc,cl_ms,prov_ms\nvt1,1557957097674.107,1557957433287.52\nvt2,1557957097674.107,1557957259404.42'
## one need to know that unix time 1557957097674.107 corresponds to ms
## the result is with ns values
df['cl_ms'] = pd.to_datetime(df['cl_ms'], unit='ms')
#but pd.to_datetime(df['cl_ms'], unit='ns') # yields bad results
## vt 2
## how to combine %m/%d%/%y $HH:%MM%SS and xxxxxx from 2 columns in timestamp
data1='acc,cl_t,cl_t_mcs,pr_t,pr_t_mcs\nvt1,15/05/2019 21:57:13,287522,15/05/2019 21:57:13,299657\nvt2,15/05/2019 21:54:19,404423,15/05/2019 21:54:19,510415'
df = pd.read_csv(StringIO(data1))
df
df['cl_time_ts']=pd.to_datetime(df['cl_t']) + df['cl_t_mcs'].apply(lambda x: datetime.timedelta(microseconds=x))
df['prov_time_ts']=pd.to_datetime(df['pr_t']) + df['pr_t_mcs'].apply(lambda x: datetime.timedelta(microseconds=x))
## todo CamelFormat columns (get rid of space) in ebaycars ipynb, mv () in colsnames