Detail: IndexHierarchy: Accessor Values

Overview: IndexHierarchy: Accessor Values

IndexHierarchy.via_values.apply(func, *args, **kwargs)
IndexHierarchy.via_values

Interface for applying functions to values (as arrays) in this container.

InterfaceValues.apply(func, *args, **kwargs)[source]
>>> ih = sf.IndexHierarchy.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z'))
>>> ih
<IndexHierarchy: ('x', 'y', 'z')>
0                                 1024    32
1                                 -2048   32
1                                 1024    32
<int64>                           <int64> <int64>
>>> ih.via_values.apply(np.sin)
<IndexHierarchy: ('x', 'y', 'z')>
0.0                               -0.15853338004399595 0.5514266812416906
0.8414709848078965                0.31305701279012343  0.5514266812416906
0.8414709848078965                -0.15853338004399595 0.5514266812416906
<float64>                         <float64>            <float64>
IndexHierarchy.via_values.__array_ufunc__(ufunc, method, *args, **kwargs)
IndexHierarchy.via_values

Interface for applying functions to values (as arrays) in this container.

InterfaceValues.__array_ufunc__(ufunc, method, *args, **kwargs)[source]

Support for applying NumPy functions directly on containers.

>>> ih = sf.IndexHierarchy.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z'))
>>> ih
<IndexHierarchy: ('x', 'y', 'z')>
0                                 1024    32
1                                 -2048   32
1                                 1024    32
<int64>                           <int64> <int64>
>>> np.sin(ih.via_values)
<IndexHierarchy: ('x', 'y', 'z')>
0.0                               -0.15853338004399595 0.5514266812416906
0.8414709848078965                0.31305701279012343  0.5514266812416906
0.8414709848078965                -0.15853338004399595 0.5514266812416906
<float64>                         <float64>            <float64>
IndexHierarchy.via_values.__call__(*, consolidate_blocks, unify_blocks, dtype)
IndexHierarchy.via_values

Interface for applying functions to values (as arrays) in this container.

InterfaceValues.__call__(*, consolidate_blocks=False, unify_blocks=False, dtype=None)[source]
Parameters:
  • consolidate_blocks – Group adjacent same-typed arrays into 2D arrays.

  • unify_blocks – Group all arrays into single array, re-typing to an appropriate dtype.

  • dtype – specify a dtype to be used in conversion before consolidation or unification, and before function application.

>>> ih = sf.IndexHierarchy.from_labels(((0, 1024, 32), (1, -2048, 32), (1, 1024, 32)), name=('x', 'y', 'z'))
>>> ih
<IndexHierarchy: ('x', 'y', 'z')>
0                                 1024    32
1                                 -2048   32
1                                 1024    32
<int64>                           <int64> <int64>
>>> np.sin(ih.via_values(unify_blocks=True))
<IndexHierarchy: ('x', 'y', 'z')>
0.0                               -0.15853338004399595 0.5514266812416906
0.8414709848078965                0.31305701279012343  0.5514266812416906
0.8414709848078965                -0.15853338004399595 0.5514266812416906
<float64>                         <float64>            <float64>

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