1.有 df 值 0 1 0 sun | 15496283461681 goal | 15322305668082 micheal | 1533647352218输出格式应为 0 1 0 sun | 2019-02-02 Sat 21:16:201 goal | 2019-02-02 Sat 21:16:202 micheal | 2019-02-02 Sat 21:16:20试过这个如何用语言得到一天s = time/1000datetime.datetime.fromtimestamp(s).strftime('%Y-%m-%d %H:%M:%S')2.具有带值的 df 如何连接这两个并获得具有纪元时间的列 Date Time 0 08-09-2017 | 05:00 PM1 16-06-17 | 10:27 AM2 04-07-17 | 03:11 PM输出 time 1549628346168 1532230566808 1533647352218
1 回答
Qyouu
TA贡献1786条经验 获得超11个赞
先用to_datetimewithunit='ms'然后Series.dt.strftime用 add%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
添加回答
举报
0/150
提交
取消