Python localtime,TypeError: cannot convert the series to <class 'int'>
Python localtime,TypeError: cannot convert the series to <class 'int'>
我有一个数据框:
enter image description here
我想在当地时间 "TimeStamps" 演出,但不想 运行。
time.localtime(data_user['TimeStamps'].astype(int))
错误:
TypeError: cannot convert the series to <class 'int'>
我怎样才能正确地做到这一点?
使用箭头包
from datetime import datetime
import arrow
now = datetime.utcnow()
print(arrow.get(now).to('local').format())
# 2020-04-25 15:55:31+01:00
像这样:
def to_local(x):
return arrow.get(x).to('local').format()
data_user['TimeStamps']= data_user['TimeStamps'].apply(to_local)
我有一个数据框: enter image description here
我想在当地时间 "TimeStamps" 演出,但不想 运行。
time.localtime(data_user['TimeStamps'].astype(int))
错误:
TypeError: cannot convert the series to <class 'int'>
我怎样才能正确地做到这一点?
使用箭头包
from datetime import datetime
import arrow
now = datetime.utcnow()
print(arrow.get(now).to('local').format())
# 2020-04-25 15:55:31+01:00
像这样:
def to_local(x):
return arrow.get(x).to('local').format()
data_user['TimeStamps']= data_user['TimeStamps'].apply(to_local)