ObjectIndex¶
Initializes an ObjectIndex with the given index.
Parameters¶
- indexlist
List of objects to be indexed.
Examples¶
>>> idx = ObjectIndex(['a', 'b', 'c'])
>>> idx.keys
array(['a', 'b', 'c'], dtype='<U1')
- Sloth.ObjectIndex.get_item()¶
Retrieves the exact index location of the given argument.
- Parameters:
- argobject
The key to retrieve the index for.
- Returns:
- int
The index of the key.
- Raises:
- KeyError
If the key is not found or invalid.
Examples
>>> idx = ObjectIndex(['a', 'b', 'c']) >>> idx.get_item('b') 1 >>> idx.get_item('d') KeyError: 'd is not a member of the index.'
- Sloth.ObjectIndex.to_pandas()¶
Converts the ObjectIndex to a pandas Index object.
- Returns:
- pd.Index
A pandas Index object.
Examples
>>> idx = ObjectIndex(['a', 'b', 'c']) >>> idx.to_pandas() Index(['a', 'b', 'c'], dtype='object')