Detail: Index: Constructor#
- Index.__init__(labels, /, *, loc_is_iloc=False, name=<object object>, dtype=None, sort_status=SortStatus.UNKNOWN)[source]#
Initializer.
- Parameters:
labels – An iterable of unique, hashable values, or another
IndexorIndexHierarchy, 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_difference(*others)[source]#
Construct a new Index based on the difference with Index, containers, or NumPy arrays. Retains order.
>>> ix1 = sf.Index.from_labels(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix2 = sf.Index.from_labels(('c', 'd', 'e', 'f'), name='y') >>> sf.Index.from_difference(ix1, ix2) <Index> a b <<U1>
- classmethod Index.from_intersection(*others)[source]#
Construct a new Index based on the intersection with Index, containers, or NumPy arrays. Identical comparisons retain order.
>>> ix1 = sf.Index.from_labels(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix2 = sf.Index.from_labels(('c', 'd', 'e', 'f'), name='y') >>> sf.Index.from_intersection(ix1, ix2) <Index> c d e <<U1>
- classmethod Index.from_labels(labels, /, *, name=None)[source]#
Construct an
Indexfrom an iterable of labels, where each label is a hashable. Provided for a compatible interface toIndexHierarchy.>>> 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>
- classmethod Index.from_union(*others)[source]#
Construct a new Index based on the union with Index, containers, or NumPy arrays. Identical comparisons retain order.
>>> ix1 = sf.Index.from_labels(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix2 = sf.Index.from_labels(('c', 'd', 'e', 'f'), name='y') >>> sf.Index.from_union(ix1, ix2) <Index> a b c d e f <<U1>
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