dataframe to timestamp

from datetime import datetime
# review_date 转为时间戳形式
def time2stamp(cmnttime):   #转时间戳函数
    cmnttime=datetime.strptime(cmnttime,'%Y-%m-%d %H:%M:%S')
    stamp=int(datetime.timestamp(cmnttime))
    return stamp
df_drop_m['review_date'].apply(lambda x: time2stamp(str(x)))

Reference:
Python quickly converts a column of a dataframe into a timestamp

Guess you like

Origin blog.csdn.net/Caiqiudan/article/details/111162865