Detail: Index: Iterator
- Index.iter_label(depth_level)
- iter_label
>>> ix = sf.Index(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix <Index: x> a b c d e <<U1> >>> tuple(ix.iter_label()) ('a', 'b', 'c', 'd', 'e')
- Index.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.Index(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix <Index: 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']
- Index.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.Index(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix <Index: x> a b c d e <<U1> >>> tuple(ix.iter_label().apply_iter(lambda l: l if l == 'b' else l.upper())) ('A', 'b', 'C', 'D', 'E')
- Index.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.Index(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix <Index: x> a b c d e <<U1> >>> tuple(ix.iter_label().apply_iter_items(lambda l: l if l == 'b' else l.upper())) ((0, 'A'), (1, 'b'), (2, 'C'), (3, 'D'), (4, 'E'))
- Index.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.Index(('a', 'b', 'c', 'd', 'e'), name='x') >>> ix <Index: 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']
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