In [1]: Timestamp('20131213 11:59:59.999999999')
Out[1]: Timestamp('2013-12-13 11:59:59.999999', tz=None)
你也可以做
In [3]: pd.Timestamp('20141213')-pd.Timedelta('1ns')
Out[3]: Timestamp('2014-12-12 23:59:59.999999999')
聽起來像是你真的想使用部分字符串切片,看到here
In [19]: s = Series(1,pd.date_range('20131212',freq='H',periods=25))
In [20]: s
Out[20]:
2013-12-12 00:00:00 1
2013-12-12 01:00:00 1
2013-12-12 02:00:00 1
..
2013-12-12 22:00:00 1
2013-12-12 23:00:00 1
2013-12-13 00:00:00 1
Freq: H, dtype: int64
In [21]: s['2013':'20131212']
Out[21]:
2013-12-12 00:00:00 1
2013-12-12 01:00:00 1
2013-12-12 02:00:00 1
..
2013-12-12 21:00:00 1
2013-12-12 22:00:00 1
2013-12-12 23:00:00 1
Freq: H, dtype: int64
任何不需要的字符串? –
運行此代碼,得到錯誤:模塊熊貓沒有屬性TimeStamp。 – bordeo
@bordeo它是時間戳 – Jeff