Detail: IndexGO: Iterator#

Overview: IndexGO: Iterator

IndexGO.iter_label(depth_level, /)
iter_label
>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> tuple(ix.iter_label())
(np.str_('a'), np.str_('b'), np.str_('c'), np.str_('d'), np.str_('e'))
IndexGO.iter_label(depth_level, /).apply(func, /, *, dtype, name, index_constructor, columns_constructor)
iter_label
IterNodeDelegate.apply(func, /, *, dtype=None, name=None, index_constructor=None, columns_constructor=None)[source]

Apply a function to each value. Returns a new container.

Parameters:
  • func – A function that takes a value.

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

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.iter_label().apply(lambda l: l if l == 'b' else l.upper())
['A' 'b' 'C' 'D' 'E']
IndexGO.iter_label(depth_level, /).apply_iter(func, /)
iter_label
IterNodeDelegate.apply_iter(func, /)[source]

Apply a function to each value. A generator of resulting values.

Parameters:

func – A function that takes a value.

Yields:

Values after function application.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> tuple(ix.iter_label().apply_iter(lambda l: l if l == 'b' else l.upper()))
('A', np.str_('b'), 'C', 'D', 'E')
IndexGO.iter_label(depth_level, /).apply_iter_items(func, /)
iter_label
IterNodeDelegate.apply_iter_items(func, /)[source]

Apply a function to each value. A generator of resulting key, value pairs.

Parameters:

func – A function that takes a value.

Yields:

Pairs of label, value after function application.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> tuple(ix.iter_label().apply_iter_items(lambda l: l if l == 'b' else l.upper()))
((np.int64(0), 'A'), (np.int64(1), np.str_('b')), (np.int64(2), 'C'), (np.int64(3), 'D'), (np.int64(4), 'E'))
IndexGO.iter_label(depth_level, /).apply_pool(func, /, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_label
IterNodeDelegate.apply_pool(func, /, *, dtype=None, name=None, index_constructor=None, max_workers=None, chunksize=1, use_threads=False)[source]

Apply a function to each value. Employ parallel processing with either the ProcessPoolExecutor or ThreadPoolExecutor.

Parameters:
  • func – A function that takes a value.

  • *

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

  • name – A hashable object to label the container.

  • max_workers – Number of parallel executors, as passed to the Thread- or ProcessPoolExecutor; None defaults to the max number of machine processes.

  • chunksize – Units of work per executor, as passed to the Thread- or ProcessPoolExecutor.

  • use_threads – Use the ThreadPoolExecutor instead of the ProcessPoolExecutor.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.iter_label().apply_pool(lambda l: l if l == 'b' else l.upper(), use_threads=True)
['A' 'b' 'C' 'D' 'E']

IndexGO: 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