Pandas怎么将Timestamp转为datetime类型(datetime,pandas,timestamp,开发技术)

时间:2024-05-04 08:30:38 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

    Pandas%E6%80%8E%E4%B9%88%E5%B0%86Timestamp%E8%BD%AC%E4%B8%BAdatetime%E7%B1%BB%E5%9E%8B

在Pandas中我们在处理时间序列的时候常用的方法有:

pd.to_datetime()

pd.date_range()

从上面代码可以看出,pandas中的时间格式是pandas._libs.tslibs.timestamps.Timestamp

但是python中常用的时间格式是datetime.datetime

to_pydatetime()

将pandas Timestamp 转为 datetime 类型

官方文档: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#from-timestamps-to-epoch

最近需要提取某一天的时刻距离0:00的分钟数,找了文档之后想到这样一个办法:

先得到距离1970-01-01的秒数

对天取余,得到距离0:00的秒数

取距离0:00的分钟数

同样的,也可以取小时数

取小时整数–当然取小时整数也有别的方法。

本文:Pandas怎么将Timestamp转为datetime类型的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:Go语言通道之缓冲通道实例分析下一篇:

41 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18