Detail: IndexHierarchyGO: Method
Overview: IndexHierarchyGO: Method
- IndexHierarchyGO.__array__(dtype=None)
Support the __array__ interface, returning an array of values.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.__array__() [[ 0 1024 32] [ 1 -2048 32] [ 1 1024 32]]
- IndexHierarchyGO.__array_ufunc__(ufunc, method, *args, **kwargs)
Support for NumPy elements or arrays on the left hand of binary operators.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> np.array((0, 1, 0)) * ih [[ 0 1024 0] [ 0 -2048 0] [ 0 1024 0]]
- IndexHierarchyGO.__bool__()
Raises ValueError to prohibit ambiguous use of truthy evaluation.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> bool(ih) ErrorNotTruthy('The truth value of a container is ambiguous. For a truthy indicator of non-empty status, use the `size` attribute.')
- IndexHierarchyGO.__copy__()
Return a shallow copy of this IndexHierarchy.
>>> import copy >>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> copy.copy(ih) <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64>
- IndexHierarchyGO.__deepcopy__(memo)
Return a deep copy of this IndexHierarchy.
>>> import copy >>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> copy.deepcopy(ih) <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64>
- IndexHierarchyGO.__len__()
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> len(ih) 3
- IndexHierarchyGO.all(axis=0, skipna=True, out=None)
Logical
and
over values along the specified axis.- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((False, True, True), (True, True, True), (False, True, False)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> False True True True True True False True False <bool> <bool> <bool> >>> ih.all() NotImplementedError('<function ufunc_all at 0x7f0c86291a80> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.any(axis=0, skipna=True, out=None)
Logical
or
over values along the specified axis.- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((False, True, True), (True, True, True), (False, True, False)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> False True True True True True False True False <bool> <bool> <bool> >>> ih.any() NotImplementedError('<function ufunc_any at 0x7f0c86291b20> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.append(value)[source]
Append a single label to this IndexHierarchyGO in-place
>>> ih = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False), ('b', 1024, True)), name='x') >>> ih <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False b 1024 True <<U1> <int64> <bool> >>> ih.append(('b', 4096, True)) >>> ih <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False b 1024 True b 4096 True <<U1> <int64> <bool>
- IndexHierarchyGO.astype[key](dtypes, *, consolidate_blocks)
- astype
Retype one or more depths. Can be used as as function to retype the entire
IndexHierarchy
; alternatively, a__getitem__
interface permits retyping selected depths.- Parameters:
dtype – A value suitable for specyfying a NumPy dtype, such as a Python type (float), NumPy array protocol strings (‘f8’), or a dtype instance.
- InterfaceIndexHierarchyAsType.__getitem__(key)[source]
Selector of columns by label.
- Parameters:
key – A loc selector, either a label, a list of labels, a slice of labels, or a Boolean array.
>>> ih = sf.IndexHierarchyGO.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 <IndexHierarchyGO: ('x', 'y', 'z')> a 1024 1517-04-01 a 2048 1789-12-31 b 0 1620-11-21 <<U1> <int64> <datetime64[D]> >>> ih.astype[1](bool) <IndexHierarchyGO: ('x', 'y', 'z')> a True 1517-04-01 a True 1789-12-31 b False 1620-11-21 <<U1> <bool> <datetime64[D]>
- IndexHierarchyGO.astype(dtype, *, consolidate_blocks)
- astype
Retype one or more depths. Can be used as as function to retype the entire
IndexHierarchy
; alternatively, a__getitem__
interface permits retyping selected depths.- Parameters:
dtype – A value suitable for specyfying a NumPy dtype, such as a Python type (float), NumPy array protocol strings (‘f8’), or a dtype instance.
- InterfaceIndexHierarchyAsType.__call__(dtype, *, consolidate_blocks=False)[source]
Apply a single
dtype
to all columns.
>>> ih = sf.IndexHierarchyGO.from_labels(((False, True, True), (True, True, True), (False, True, False)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> False True True True True True False True False <bool> <bool> <bool> >>> ih.astype(str) <IndexHierarchyGO: ('x', 'y', 'z')> False True True True True True False True False <<U5> <<U5> <<U5>
- IndexHierarchyGO.copy()
Return a shallow copy of this IndexHierarchy.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.copy() <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64>
- IndexHierarchyGO.cumprod(axis=0, skipna=True)
Return the cumulative product over the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.cumprod() NotImplementedError('<function cumprod at 0x7f0cbe502840> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.cumsum(axis=0, skipna=True)
Return the cumulative sum over the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.cumsum() NotImplementedError('<function cumsum at 0x7f0cbe5020c0> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.difference(*others)
Perform difference with another Index, container, or NumPy array. Retains order.
>>> ih1 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih1 <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih2 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('b', 1024, True)), name='y') >>> ih2 <IndexHierarchyGO: y> a 1024 True b 1024 True <<U1> <int64> <bool> >>> ih1.difference(ih2) <IndexHierarchy> a 2048 False a 2048 True <<U1> <int64> <bool>
- IndexHierarchyGO.dropfalsy(*, condition=<function all>)
Return a new obj:IndexHierarchy after removing labels where any or all values are falsy. The condition is determined by a NumPy ufunc that process the Boolean array returned by
isna()
; the default isnp.all
.- Parameters:
* –
condition –
>>> ih = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('', 0, False), ('b', 1024, True)), name='x') >>> ih <IndexHierarchyGO: x> a 1024 True 0 False b 1024 True <<U1> <int64> <bool> >>> ih.dropfalsy() <IndexHierarchyGO: x> a 1024 True b 1024 True <<U1> <int64> <bool>
- IndexHierarchyGO.dropna(*, condition=<function all>)
Return a new obj:IndexHierarchy after removing labels where any or all values are NA (NaN or None). The condition is determined by a NumPy ufunc that process the Boolean array returned by
isna()
; the default isnp.all
.- Parameters:
* –
condition –
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024), (1, 2048), (np.nan, np.nan)), name=('x', 'y')) >>> ih <IndexHierarchyGO: ('x', 'y')> 0.0 1024.0 1.0 2048.0 nan nan <float64> <float64> >>> ih.dropna() <IndexHierarchyGO: ('x', 'y')> 0.0 1024.0 1.0 2048.0 <float64> <float64>
- IndexHierarchyGO.equals(other, *, compare_name=False, compare_dtype=False, compare_class=False, skipna=True)
Return a
bool
from comparison to any other object.- Parameters:
compare_name – Include equality of the container’s name (and all composed containers) in the comparison.
compare_dtype – Include equality of the container’s dtype (and all composed containers) in the comparison.
compare_class – Include equality of the container’s class (and all composed containers) in the comparison.
skipna – If True, comparisons between missing values are equal.
>>> ih1 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih1 <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih2 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('b', 1024, True)), name='y') >>> ih2 <IndexHierarchyGO: y> a 1024 True b 1024 True <<U1> <int64> <bool> >>> ih1.equals(ih2) False
- IndexHierarchyGO.extend(other)[source]
Extend this IndexHierarchyGO in-place
>>> ih1 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False), ('b', 1024, True)), name='x') >>> ih1 <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False b 1024 True <<U1> <int64> <bool> >>> ih2 = sf.IndexHierarchyGO.from_labels((('b', 2048, True), ('c', 4096, True), ('c', 1024, True)), name='y') >>> ih2 <IndexHierarchyGO: y> b 2048 True c 4096 True c 1024 True <<U1> <int64> <bool> >>> ih1.extend(ih2) >>> ih1 <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False b 1024 True b 2048 True c 4096 True c 1024 True <<U1> <int64> <bool>
- IndexHierarchyGO.fillfalsy(value)
Return an
IndexHierarchy
after replacing falsy values with the supplied value.- Parameters:
value – Value to be used to replace missing values (NaN or None).
>>> ih = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('', 0, False), ('b', 1024, True)), name='x') >>> ih <IndexHierarchyGO: x> a 1024 True 0 False b 1024 True <<U1> <int64> <bool> >>> ih.fillfalsy(-1) <IndexHierarchyGO: x> a 1024 True -1 -1 -1 b 1024 True <object> <int64> <object>
- IndexHierarchyGO.fillna(value)
Return an
IndexHierarchy
after replacing NA (NaN or None) with the supplied value.- Parameters:
value – Value to be used to replace missing values (NaN or None).
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024), (1, 2048), (np.nan, np.nan)), name=('x', 'y')) >>> ih <IndexHierarchyGO: ('x', 'y')> 0.0 1024.0 1.0 2048.0 nan nan <float64> <float64> >>> ih.fillna(0) <IndexHierarchyGO: ('x', 'y')> 0.0 1024.0 1.0 2048.0 0.0 0.0 <float64> <float64>
- IndexHierarchyGO.flat()
Return a flat, one-dimensional index of tuples for each level.
>>> ih = sf.IndexHierarchyGO.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 <IndexHierarchyGO: ('x', 'y', 'z')> a 1024 1517-04-01 a 2048 1789-12-31 b 0 1620-11-21 <<U1> <int64> <datetime64[D]> >>> ih.flat().display_wide() <IndexGO: ('x', 'y', 'z')> ('a', 1024, numpy.datetime64('1517-04-01')) ('a', 2048, numpy.datetime64('1789-12-31')) ('b', 0, numpy.datetime64('1620-11-21')) <object>
- IndexHierarchyGO.head(count=5)
Return a
Index
consisting only of the top elements as specified bycount
.- Parameters:
count – Number of elements to be returned from the top of the
Index
>>> ih = sf.IndexHierarchyGO.from_product(('a', 'b', 'c'), ('1517-04-01', '1620-11-21'), name='x', index_constructors=(sf.Index, sf.IndexDate)) >>> ih <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]> >>> ih.head(2) <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 <<U1> <datetime64[D]>
- IndexHierarchyGO.iloc_searchsorted(values, *, side_left=True)
Given a sorted
Series
, return the iloc (integer) position(s) at which insertion invalues
would retain sort order.- Parameters:
values – a single value, or iterable of values.
side_left – If True, the index of the first suitable location found is given, else return the last such index. If matching an existing value, side_left==True will return that position, side_left==Right will return the next position (or the length).
>>> ih = sf.IndexHierarchyGO.from_product(('a', 'b', 'c'), ('1517-04-01', '1620-11-21'), name='x', index_constructors=(sf.Index, sf.IndexDate)) >>> ih <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]> >>> ih.iloc_searchsorted(('b', np.datetime64('1620-11-21'))) 3
- IndexHierarchyGO.index_at_depth(depth_level=0)
Return an index, or a tuple of indices for the
depth_level
specified.- Parameters:
depth_level – a single depth level, or iterable depth of depth levels.
>>> ih = sf.IndexHierarchyGO.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 <IndexHierarchyGO: ('x', 'y', 'z')> a 1024 1517-04-01 a 2048 1789-12-31 b 0 1620-11-21 <<U1> <int64> <datetime64[D]> >>> ih.index_at_depth(0) <IndexGO> a b <<U1> >>> ih.index_at_depth([2, 0]) (<IndexDateGO> 1517-04-01 1789-12-31 1620-11-21 <datetime64[D]>, <IndexGO> a b <<U1>)
- IndexHierarchyGO.indexer_at_depth(depth_level=0)
Return the indexers for the
depth_level
specified. Array will 2D if multiple depths are selected.- Parameters:
depth_level – a single depth level, or iterable depth of depth levels.
>>> ih = sf.IndexHierarchyGO.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 <IndexHierarchyGO: ('x', 'y', 'z')> a 1024 1517-04-01 a 2048 1789-12-31 b 0 1620-11-21 <<U1> <int64> <datetime64[D]> >>> ih.indexer_at_depth(0) [0 0 1] >>> ih.indexer_at_depth([2, 0]) [[0 1 2] [0 0 1]]
- IndexHierarchyGO.intersection(*others)
Perform intersection with one or many Index, container, or NumPy array. Identical comparisons retain order.
>>> ih1 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih1 <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih2 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('b', 1024, True)), name='y') >>> ih2 <IndexHierarchyGO: y> a 1024 True b 1024 True <<U1> <int64> <bool> >>> ih1.intersection(ih2) <IndexHierarchy> a 1024 True <<U1> <int64> <bool>
- IndexHierarchyGO.isfalsy()
Return a same-shaped, Boolean
ndarray
indicating which values are falsy.>>> ih = sf.IndexHierarchyGO.from_labels((('b', np.nan, True), ('', 4096, None), ('c', 0, False)), name='y') >>> ih.isfalsy() [[False True False] [ True False True] [False True True]]
- IndexHierarchyGO.isin(other)
Return a Boolean array showing True where one or more of the passed in iterable of labels is found in the index.
>>> ih = sf.IndexHierarchyGO.from_product(('a', 'b', 'c'), ('1517-04-01', '1620-11-21'), name='x', index_constructors=(sf.Index, sf.IndexDate)) >>> ih <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]> >>> ih.isin((('c', np.datetime64('1517-04-01')), ('a', np.datetime64('1620-11-21')))) [False True False False True False]
- IndexHierarchyGO.isna()
Return a same-shaped, Boolean
ndarray
indicating which values are NaN or None.>>> ih = sf.IndexHierarchyGO.from_labels((('b', np.nan, True), ('', 4096, None), ('c', 0, False)), name='y') >>> ih.isna() [[False True False] [False False True] [False False False]]
- IndexHierarchyGO.label_widths_at_depth(depth_level=0)
A generator of pairs, where each pair is the label and the contiguous count of that label found at the depth specified by
depth_level
.- Parameters:
depth_level – a depth level, starting from zero.
>>> ih = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False), ('b', 1024, True)), name='x') >>> ih <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False b 1024 True <<U1> <int64> <bool> >>> tuple(ih.label_widths_at_depth(0)) (('a', 3), ('b', 1)) >>> tuple(ih.label_widths_at_depth(1)) ((1024, 1), (2048, 2), (1024, 1)) >>> tuple(ih.label_widths_at_depth(2)) ((True, 2), (False, 1), (True, 1))
- IndexHierarchyGO.level_add(level, *, index_constructor=None)
Return an IndexHierarchy with a new root (outer) level added.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024), (1, 2048), (np.nan, np.nan)), name=('x', 'y')) >>> ih <IndexHierarchyGO: ('x', 'y')> 0.0 1024.0 1.0 2048.0 nan nan <float64> <float64> >>> ih.level_add('A') <IndexHierarchyGO: ('x', 'y')> A 0.0 1024.0 A 1.0 2048.0 A nan nan <<U1> <float64> <float64>
- IndexHierarchyGO.level_drop(count=1)
Return an IndexHierarchy with one or more leaf levels removed.
- Parameters:
count – A positive value is the number of depths to remove from the root (outer) side of the hierarchy; a negative value is the number of depths to remove from the leaf (inner) side of the hierarchy.
>>> ih = sf.IndexHierarchyGO.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 <IndexHierarchyGO: ('x', 'y', 'z')> a 1024 1517-04-01 a 2048 1789-12-31 b 0 1620-11-21 <<U1> <int64> <datetime64[D]> >>> ih.level_drop() <IndexHierarchyGO: ('y', 'z')> 1024 1517-04-01 2048 1789-12-31 0 1620-11-21 <int64> <datetime64[D]>
- IndexHierarchyGO.loc_searchsorted(values, *, side_left=True, fill_value=nan)
Given a sorted
Series
, return the loc (label) position(s) at which insertion invalues
would retain sort order.- Parameters:
values – a single value, or iterable of values.
side_left – If True, the index of the first suitable location found is given, else return the last such index. If matching an existing value, side_left==True will return that position, side_left==Right will return the next position (or the length).
fill_value – A value to be used to fill the label beyond the last label.
>>> ih = sf.IndexHierarchyGO.from_product(('a', 'b', 'c'), ('1517-04-01', '1620-11-21'), name='x', index_constructors=(sf.Index, sf.IndexDate)) >>> ih <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]> >>> ih.loc_searchsorted(('b', np.datetime64('1620-11-21'))) ('b', numpy.datetime64('1620-11-21'))
- IndexHierarchyGO.loc_to_iloc(key)
Given a label (loc) style key (either a label, a list of labels, a slice, an HLoc object, or a Boolean selection), return the index position (iloc) style key. Keys that are not found will raise a KeyError or a sf.LocInvalid error.
- Parameters:
key – a label key.
>>> ih = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False), ('b', 1024, True)), name='x') >>> ih <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False b 1024 True <<U1> <int64> <bool> >>> ih.loc_to_iloc(('b', 1024, True)) 3 >>> ih.loc_to_iloc([('a', 1024, True), ('b', 1024, True)]) [0, 3] >>> ih.loc_to_iloc(slice(('a', 2048, False), None)) slice(2, None, None)
- IndexHierarchyGO.max(axis=0, skipna=True, out=None)
Return the maximum along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.max() [ 1 1024 32]
- IndexHierarchyGO.mean(axis=0, skipna=True, out=None)
Return the mean along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.mean() NotImplementedError('<function mean at 0x7f0cbe502de0> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.median(axis=0, skipna=True, out=None)
Return the median along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.median() NotImplementedError('<function median at 0x7f0c95a83060> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.min(axis=0, skipna=True, out=None)
Return the minimum along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.min() [ 0 1024 32]
- IndexHierarchyGO.notfalsy()
Return a same-shaped, Boolean
ndarray
indicating which values are falsy.>>> ih = sf.IndexHierarchyGO.from_labels((('b', np.nan, True), ('', 4096, None), ('c', 0, False)), name='y') >>> ih.notfalsy() [[ True False True] [False True False] [ True False False]]
- IndexHierarchyGO.notna()
Return a same-shaped, Boolean
ndarray
indicating which values are NaN or None.>>> ih = sf.IndexHierarchyGO.from_labels((('b', np.nan, True), ('', 4096, None), ('c', 0, False)), name='y') >>> ih.notna() [[ True False True] [ True True False] [ True True True]]
- IndexHierarchyGO.prod(axis=0, skipna=True, allna=1, out=None)
Return the product along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.prod() NotImplementedError('<function prod at 0x7f0cbe502700> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.rehierarch(depth_map, *, index_constructors=None)
Return a new
IndexHierarchy
that conforms to the new depth assignments given be depth_map.>>> ih = sf.IndexHierarchyGO.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih <IndexHierarchyGO: x> b 1024 True a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih.rehierarch([2, 0, 1]) <IndexHierarchyGO> True b 1024 True a 1024 True a 2048 False a 2048 <bool> <<U1> <int64>
- IndexHierarchyGO.relabel(mapper)
Return a new IndexHierarchy with labels replaced by the callable or mapping; order will be retained. If a mapping is used, the mapping should map tuple representation of labels, and need not map all origin keys.
>>> ih = sf.IndexHierarchyGO.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih <IndexHierarchyGO: x> b 1024 True a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih.relabel(lambda l: (l[0], l[1], str(l[2])[0])) <IndexHierarchyGO: x> b 1024 T a 1024 T a 2048 T a 2048 F <<U1> <int64> <<U1>
- IndexHierarchyGO.relabel_at_depth(mapper, depth_level=0)
Return a new
IndexHierarchy
after applying mapper to a level or each individual level specified by depth_level.- mapper can be a callable, mapping, or iterable.
If a callable, it must accept a single hashable, and return a single hashable.
If a mapping, it must map a single hashable to a single hashable.
If a iterable, it must be the same length as self.
This call:
>>> index.relabel_at_depth(mapper, depth_level=[0, 1, 2])
is equivalent to:
>>> for level in [0, 1, 2]: >>> index = index.relabel_at_depth(mapper, depth_level=level)
albeit more efficient.
>>> ih = sf.IndexHierarchyGO.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih <IndexHierarchyGO: x> b 1024 True a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih.relabel_at_depth(lambda l: str(l)[0], depth_level=[1, 2]) <IndexHierarchyGO: x> b 1 T a 1 T a 2 T a 2 F <<U1> <<U1> <<U1>
- IndexHierarchyGO.rename(name)
Return a new IndexHierarchy with an updated name attribute.
>>> ih = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False), ('b', 1024, True)), name='x') >>> ih <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False b 1024 True <<U1> <int64> <bool> >>> ih.rename('y') <IndexHierarchyGO: y> a 1024 True a 2048 True a 2048 False b 1024 True <<U1> <int64> <bool>
- IndexHierarchyGO.roll(shift)
Return an
IndexHierarchy
with values rotated forward and wrapped around (with a positive shift) or backward and wrapped around (with a negative shift).>>> ih = sf.IndexHierarchyGO.from_product(('a', 'b', 'c'), ('1517-04-01', '1620-11-21'), name='x', index_constructors=(sf.Index, sf.IndexDate)) >>> ih <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]> >>> ih.roll(2) <IndexHierarchyGO: x> c 1517-04-01 c 1620-11-21 a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 <<U1> <datetime64[D]>
- IndexHierarchyGO.sample(count=1, *, seed=None)
Randomly (optionally made deterministic with a fixed seed) extract items from the container to return a subset of the container.
- Parameters:
select. (Number of elements to) –
selection. (Initial state of random) –
>>> ih = sf.IndexHierarchyGO.from_product(('a', 'b', 'c'), ('1517-04-01', '1620-11-21'), name='x', index_constructors=(sf.Index, sf.IndexDate)) >>> ih <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]> >>> ih.sample(2, seed=0) <IndexHierarchyGO: x> b 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]>
- IndexHierarchyGO.sort(*, ascending=True, kind='mergesort', key=None)
Return a new Index with the labels sorted.
- Parameters:
ascendings – Boolean, or iterable of Booleans; if
True
, the lowest ranks correspond to the lowest values; if an iterable, apply per column or row. The default isTrue
.kind – Name of the sort algorithm as passed to NumPy.
key – A function that is used to pre-process the selected columns or rows and derive new values to sort by.
>>> ih = sf.IndexHierarchyGO.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih <IndexHierarchyGO: x> b 1024 True a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih.sort() <IndexHierarchyGO: x> a 1024 True a 2048 False a 2048 True b 1024 True <<U1> <int64> <bool> >>> ih.sort(ascending=False) <IndexHierarchyGO: x> b 1024 True a 2048 True a 2048 False a 1024 True <<U1> <int64> <bool>
- IndexHierarchyGO.std(axis=0, skipna=True, ddof=0, out=None)
Return the standard deviaton along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.std() NotImplementedError('functools.partial(<function std at 0x7f0cbe4f8d70>, ddof=0) for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.sum(axis=0, skipna=True, allna=0, out=None)
Sum values along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.sum() NotImplementedError('<function sum at 0x7f0cbe501d00> for IndexHierarchyGO is not defined; convert to `Frame`.')
- IndexHierarchyGO.tail(count=5)
Return a
Index
consisting only of the bottom elements as specified bycount
.- Parameters:
count – Number of elements to be returned from the bottom of the
Index
>>> ih = sf.IndexHierarchyGO.from_product(('a', 'b', 'c'), ('1517-04-01', '1620-11-21'), name='x', index_constructors=(sf.Index, sf.IndexDate)) >>> ih <IndexHierarchyGO: x> a 1517-04-01 a 1620-11-21 b 1517-04-01 b 1620-11-21 c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]> >>> ih.tail(2) <IndexHierarchyGO: x> c 1517-04-01 c 1620-11-21 <<U1> <datetime64[D]>
- IndexHierarchyGO.union(*others)
Perform union with another Index, container, or NumPy array. Identical comparisons retain order.
>>> ih1 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x') >>> ih1 <IndexHierarchyGO: x> a 1024 True a 2048 True a 2048 False <<U1> <int64> <bool> >>> ih2 = sf.IndexHierarchyGO.from_labels((('a', 1024, True), ('b', 1024, True)), name='y') >>> ih2 <IndexHierarchyGO: y> a 1024 True b 1024 True <<U1> <int64> <bool> >>> ih1.union(ih2) <IndexHierarchy> a 2048 False a 1024 True b 1024 True a 2048 True <<U1> <int64> <bool>
- IndexHierarchyGO.unique(depth_level=0, order_by_occurrence=False)
Return a NumPy array of unique values.
- Parameters:
depth_level – Specify a single depth or multiple depths in an iterable.
order_by_occurrence – if True, values are ordered by when they first appear
- Returns:
numpy.ndarray
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024), (1, 2048), (np.nan, np.nan)), name=('x', 'y')) >>> ih <IndexHierarchyGO: ('x', 'y')> 0.0 1024.0 1.0 2048.0 nan nan <float64> <float64> >>> ih.unique() [ 0. 1. nan]
- IndexHierarchyGO.values_at_depth(depth_level=0)
Return an NP array for the
depth_level
specified.- Parameters:
depth_level – a single depth level, or iterable depth of depth levels.
>>> ih = sf.IndexHierarchyGO.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 <IndexHierarchyGO: ('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']
- IndexHierarchyGO.var(axis=0, skipna=True, ddof=0, out=None)
Return the variance along the specified axis.
- Parameters:
axis – Axis, defaulting to axis 0.
skipna – Skip missing (NaN) values, defaulting to True.
>>> ih = sf.IndexHierarchyGO.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z')) >>> ih <IndexHierarchyGO: ('x', 'y', 'z')> 0 1024 32 1 -2048 32 1 1024 32 <int64> <int64> <int64> >>> ih.var() NotImplementedError('functools.partial(<function var at 0x7f0cbe4f8f70>, ddof=0) for IndexHierarchyGO is not defined; convert to `Frame`.')
IndexHierarchyGO: 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