Detail: Index: Constructor

Overview: Index: Constructor

Index.__init__(labels, *, loc_is_iloc=False, name=<object object>, dtype=None)[source]

Initializer.

Parameters:
  • labels – An iterable of unique, hashable values, or another Index or IndexHierarchy, to be used as the labels of the index.

  • name – A hashable object to label the container.

  • loc_is_iloc – Optimization when a contiguous integer index is provided as labels. Generally only set by internal clients.

  • dtype – A value suitable for specyfying a NumPy dtype, such as a Python type (float), NumPy array protocol strings (‘f8’), or a dtype instance.

>>> sf.Index(('a', 'b', 'c', 'd', 'e'), name='x')
<Index: x>
a
b
c
d
e
<<U1>
classmethod Index.from_labels(labels, *, name=None)[source]

Construct an Index from an iterable of labels, where each label is a hashable. Provided for a compatible interface to IndexHierarchy.

>>> sf.Index.from_labels(('a', 'b', 'c', 'd', 'e'), name='x')
<Index: x>
a
b
c
d
e
<<U1>
classmethod Index.from_pandas(value)

Given a Pandas index, return the appropriate IndexBase derived class.

>>> ix = pd.Index(('a', 'b', 'c', 'd', 'e'), name='x')
>>> sf.Index.from_pandas(ix)
<Index: x>
a
b
c
d
e
<object>

Index: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic