1In [23]: df.head()
2Out[23]:
3 date price
40 1349720105 12.08
51 1349806505 12.35
62 1349892905 12.15
73 1349979305 12.19
84 1350065705 12.15
9In [25]: df['date'] = pd.to_datetime(df['date'],unit='s')
10
11In [26]: df.head()
12Out[26]:
13 date price
140 2012-10-08 18:15:05 12.08
151 2012-10-09 18:15:05 12.35
162 2012-10-10 18:15:05 12.15
173 2012-10-11 18:15:05 12.19
184 2012-10-12 18:15:05 12.15
19
20In [27]: df.dtypes
21Out[27]:
22date datetime64[ns]
23price float64
24dtype: object
25
1dates = pd.to_datetime(['2019-01-15 13:30:00'])
2(dates - pd.Timestamp("1970-01-01")) // pd.Timedelta('1s')
3# Int64Index([1547559000], dtype='int64')
1# convert unix timestamp to datetime UTC
2df['datetime'] = df['_ts'].map(lambda x: pendulum.from_timestamp(x))
3df = df.set_index('datetime')
4# convert timezone from UTC to GMT+7
5df.index = df.index.tz_convert('Asia/Bangkok')