Python是進行數據分析的一種出色語言,主要是因為以數據為中心的python軟件包具有奇妙的生態係統。 Pandas是其中的一種,使導入和分析數據更加容易。
Pandas TimedeltaIndex.get_slice_bound()
函數計算與給定標簽對應的切片範圍。該函數返回給定標簽的最左位置(如果side =='right',則為one-past-the-rightmost)位置。
用法: TimedeltaIndex.get_slice_bound(label, side, kind)
參數:
label: Object
side:{'左右'}
kind:{“ ix”,“ loc”,“ getitem”}
返回:整型
範例1:采用TimedeltaIndex.get_slice_bound()
函數在給定的TimedeltaIndex對象中查找值的左切片邊界。
# importing pandas as pd
import pandas as pd
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['3 days 06:05:01.000030', '1 days 06:05:01.000030',
'3 days 06:05:01.000030', '1 days 02:00:00',
'21 days 06:15:01.000030'])
# Print the TimedeltaIndex object
print(tidx)
輸出:
現在我們將使用TimedeltaIndex.get_slice_bound()
函數以查找“ 1天02:00:00”的左邊界。
# find the left slice bound for passed value
tidx.get_slice_bound('1 days 02:00:00', side ='left', kind ='loc')
輸出:
正如我們在輸出中看到的,TimedeltaIndex.get_slice_bound()
函數已返回3作為給定TimedeltaIndex對象中傳遞的值的切片邊界。
範例2:采用TimedeltaIndex.get_slice_bound()
函數在給定的TimedeltaIndex對象中查找值的左切片邊界。
輸出:
正如我們在輸出中看到的,TimedeltaIndex.get_slice_bound()
函數已返回4作為給定TimedeltaIndex對象中傳遞的值的切片邊界。
相關用法
- Python pandas.map()用法及代碼示例
- Python Pandas Series.all()用法及代碼示例
- Python Pandas TimedeltaIndex.max用法及代碼示例
- Python Pandas Series.le()用法及代碼示例
- Python Pandas Series.eq()用法及代碼示例
- Python Pandas Series.ne()用法及代碼示例
- Python Pandas Series.ge()用法及代碼示例
- Python Pandas Series.lt()用法及代碼示例
- Python Pandas Series.abs()用法及代碼示例
- Python Pandas Series.sum()用法及代碼示例
- Python Pandas DataFrame.ix[ ]用法及代碼示例
- Python Pandas dataframe.sub()用法及代碼示例
- Python Pandas Timestamp.day用法及代碼示例
- Python Pandas Series.str.pad()用法及代碼示例
注:本文由純淨天空篩選整理自Shubham__Ranjan大神的英文原創作品 Python | Pandas TimedeltaIndex.get_slice_bound。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。