Detail: IndexHierarchy: Dictionary-Like

Overview: IndexHierarchy: Dictionary-Like

IndexHierarchy.__contains__(value)[source]

Determine if a label value is contained in this Index.

>>> ih = sf.IndexHierarchy.from_labels((('a', 1024, '1517-04-01'), ('a', 2048, '1789-12-31'), ('b', 0, '1620-11-21')), index_constructors=(sf.Index, sf.Index, sf.IndexDate), name=('x', 'y', 'z'))
>>> ih
<IndexHierarchy: ('x', 'y', 'z')>
a                                 1024    1517-04-01
a                                 2048    1789-12-31
b                                 0       1620-11-21
<<U1>                             <int64> <datetime64[D]>
>>> ih.__contains__('a')
RuntimeError('Invalid key length for a; must be length 3.')
IndexHierarchy.__iter__()[source]

Iterate over labels.

>>> ih = sf.IndexHierarchy.from_labels((('a', 1024, '1517-04-01'), ('a', 2048, '1789-12-31'), ('b', 0, '1620-11-21')), index_constructors=(sf.Index, sf.Index, sf.IndexDate), name=('x', 'y', 'z'))
>>> ih
<IndexHierarchy: ('x', 'y', 'z')>
a                                 1024    1517-04-01
a                                 2048    1789-12-31
b                                 0       1620-11-21
<<U1>                             <int64> <datetime64[D]>
>>> tuple(ih.__iter__())
(('a', 1024, numpy.datetime64('1517-04-01')), ('a', 2048, numpy.datetime64('1789-12-31')), ('b', 0, numpy.datetime64('1620-11-21')))
IndexHierarchy.__reversed__()[source]

Returns a reverse iterator on the index labels.

>>> ih = sf.IndexHierarchy.from_labels((('a', 1024, '1517-04-01'), ('a', 2048, '1789-12-31'), ('b', 0, '1620-11-21')), index_constructors=(sf.Index, sf.Index, sf.IndexDate), name=('x', 'y', 'z'))
>>> ih
<IndexHierarchy: ('x', 'y', 'z')>
a                                 1024    1517-04-01
a                                 2048    1789-12-31
b                                 0       1620-11-21
<<U1>                             <int64> <datetime64[D]>
>>> tuple(ih.__reversed__())
(('b', 0, datetime.date(1620, 11, 21)), ('a', 2048, datetime.date(1789, 12, 31)), ('a', 1024, datetime.date(1517, 4, 1)))
IndexHierarchy.values

A 2D NumPy array of all values in the IndexHierarchy. As this is a single array, heterogenous columnar types might be coerced to a compatible type.

>>> ih = sf.IndexHierarchy.from_labels((('a', 1024, '1517-04-01'), ('a', 2048, '1789-12-31'), ('b', 0, '1620-11-21')), index_constructors=(sf.Index, sf.Index, sf.IndexDate), name=('x', 'y', 'z'))
>>> ih
<IndexHierarchy: ('x', 'y', 'z')>
a                                 1024    1517-04-01
a                                 2048    1789-12-31
b                                 0       1620-11-21
<<U1>                             <int64> <datetime64[D]>
>>> ih.values_at_depth(0)
['a' 'a' 'b']
>>> ih.values_at_depth(2)
['1517-04-01' '1789-12-31' '1620-11-21']

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