python 时间戳转时间 timestamp to time

pandas从postgreSQL数据库读取时间戳(timestamp)类型,转成python的时间(time)类型

使用datetime模块的datetime类的time方法

import datetime


print(type(df_order['time_start']),'\t',df_order['time_start'])
order_time_start = datetime.datetime.time(df_order['time_start'])
print(type(order_time_start),'\t',order_time_start)


# 运行结果 #
# <class 'pandas._libs.tslibs.timestamps.Timestamp'>       2016-11-01 18:21:27
# <class 'datetime.time'>          18:21:27
# 运行结果 #
posted @ 2021-03-10 13:34  贝可考拉  阅读(830)  评论(0编辑  收藏  举报