1。拥有df值
0 1
0 sun | 1549628346168
1 goal | 1532230566808
2 micheal | 1533647352218
输出应采用
的格式 0 1
0 sun | 2019-02-02 Sat 21:16:20
1 goal | 2019-02-02 Sat 21:16:20
2 micheal | 2019-02-02 Sat 21:16:20
尝试了这种如何获得言语的机会
s = time/1000
datetime.datetime.fromtimestamp(s).strftime('%Y-%m-%d %H:%M:%S')
2。
具有df值,该值如何连接这两个值并获得具有纪元时间的列
Date Time
0 08-09-2017 | 05:00 PM
1 16-06-17 | 10:27 AM
2 04-07-17 | 03:11 PM
输出
time
1549628346168
1532230566808
1533647352218
答案 0 :(得分:3)
先将to_datetime
与unit='ms'
一起使用,然后再将Series.dt.strftime
与%a
添加几天,再检查http://strftime.org/:
df[1] = pd.to_datetime(df[1], unit='ms').dt.strftime('%Y-%m-%d %a %H:%M:%S')
print (df)
0 1
0 sun 2019-02-08 Fri 12:19:06
1 goal 2018-07-22 Sun 03:36:06
2 micheal 2018-08-07 Tue 13:09:12
编辑:
df['dt'] = pd.to_datetime(df['Date'] + ' ' + df['Time']).astype(np.int64) // 10**9
print (df)
Date Time dt
0 08-09-2017 05:00 PM 1502298000
1 16-06-17 10:27 AM 1497608820
2 04-07-17 03:11 PM 1491577860