没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论















pandas中中Timestamp类用法详解类用法详解
主要为大家详细介绍了pandas中Timestamp类用法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
由于网上关于Timestamp类的资料比较少,而且官网上面介绍的很模糊,本文只是对如何创建Timestamp类对象进行简要介
绍,详情请读者自行查阅文档。
以下有两种方式可以创建一个Timestamp对象:
1. Timestamp()的构造方法
import pandas as pd
from datetime import datetime as dt
p1=pd.Timestamp(2017,6,19)
p2=pd.Timestamp(dt(2017,6,19,hour=9,minute=13,second=45))
p3=pd.Timestamp("2017-6-19 9:13:45")
print("type of p1:",type(p1))
print(p1)
print("type of p2:",type(p2))
print(p2)
print("type of p3:",type(p3))
print(p3)
输出:
('type of p1:', <class 'pandas.tslib.Timestamp'>)
2017-06-19 00:00:00
('type of p2:', <class 'pandas.tslib.Timestamp'>)
2017-06-19 09:13:45
('type of p3:', <class 'pandas.tslib.Timestamp'>)
2017-06-19 09:13:45
2. to_datetime()方法
import pandas as pd
from datetime import datetime as dt
p4=pd.to_datetime("2017-6-19 9:13:45")
p5=pd.to_datetime(dt(2017,6,19,hour=9,minute=13,second=45))
print("type of p4:",type(p4))
print(p4)
print("type of p5:",type(p5))
print(p5)
输出:
('type of p4:', <class 'pandas.tslib.Timestamp'>)
2017-06-19 09:13:45
('type of p5:', <class 'pandas.tslib.Timestamp'>)
2017-06-19 09:13:45
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。
资源评论


weixin_38639747
- 粉丝: 7
- 资源: 902
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
