欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

pandas中Timestamp類用法詳解

 更新時間:2017年12月11日 11:11:42   作者:neu_張康  
這篇文章主要為大家詳細(xì)介紹了pandas中Timestamp類用法,具有一定的參考價值,感興趣的小伙伴們可以參考一下

由于網(wǎng)上關(guān)于Timestamp類的資料比較少,而且官網(wǎng)上面介紹的很模糊,本文只是對如何創(chuàng)建Timestamp類對象進(jìn)行簡要介紹,詳情請讀者自行查閱文檔。

以下有兩種方式可以創(chuàng)建一個Timestamp對象:

1. Timestamp()的構(gòu)造方法

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

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論