Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Index.get_slice_bound#

Index.get_slice_bound(label,side)[source]#

Calculate slice bound that corresponds to given label.

Returns leftmost (one-past-the-rightmost ifside=='right') positionof given label.

Parameters:
labelobject
side{‘left’, ‘right’}
Returns:
int

Index of label.

See also

Index.get_loc

Get integer location, slice or boolean mask for requested label.

Examples

>>>idx=pd.RangeIndex(5)>>>idx.get_slice_bound(3,'left')3
>>>idx.get_slice_bound(3,'right')4

Iflabel is non-unique in the index, an error will be raised.

>>>idx_duplicate=pd.Index(['a','b','a','c','d'])>>>idx_duplicate.get_slice_bound('a','left')Traceback (most recent call last):KeyError:Cannot get left slice bound for non-unique label: 'a'

[8]ページ先頭

©2009-2025 Movatter.jp