首页 > 编程语言 > 详细

python 时间戳转时间 timestamp to time

时间:2021-03-10 15:08:22      阅读:34      评论:0      收藏:0      [点我收藏+]

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
# 运行结果 #

python 时间戳转时间 timestamp to time

原文:https://www.cnblogs.com/liuwenzhen/p/14511098.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!