Detail: IndexHourGO: Iterator

Overview: IndexHourGO: Iterator

IndexHourGO.iter_label(depth_level)
iter_label
>>> ix = sf.IndexHourGO(('1517-04-01', '1517-12-31', '1517-06-30'))
>>> ix
<IndexHourGO>
1517-04-01T00
1517-12-31T00
1517-06-30T00
<datetime64[h]>
>>> tuple(ix.iter_label())
(numpy.datetime64('1517-04-01T00','h'), numpy.datetime64('1517-12-31T00','h'), numpy.datetime64('1517-06-30T00','h'))
IndexHourGO.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.IndexHourGO(('1517-04-01', '1517-12-31', '1517-06-30'))
>>> ix
<IndexHourGO>
1517-04-01T00
1517-12-31T00
1517-06-30T00
<datetime64[h]>
>>> ix.iter_label().apply(lambda l: l.astype('<M8[ms]').astype(object).year)
[1517 1517 1517]
IndexHourGO.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.IndexHourGO(('1517-04-01', '1517-12-31', '1517-06-30'))
>>> ix
<IndexHourGO>
1517-04-01T00
1517-12-31T00
1517-06-30T00
<datetime64[h]>
>>> tuple(ix.iter_label().apply_iter(lambda l: l.astype('<M8[ms]').astype(object)))
(datetime.datetime(1517, 4, 1, 0, 0), datetime.datetime(1517, 12, 31, 0, 0), datetime.datetime(1517, 6, 30, 0, 0))
IndexHourGO.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.IndexHourGO(('1517-04-01', '1517-12-31', '1517-06-30'))
>>> ix
<IndexHourGO>
1517-04-01T00
1517-12-31T00
1517-06-30T00
<datetime64[h]>
>>> tuple(ix.iter_label().apply_iter_items(lambda l: l.astype('<M8[ms]').astype(object)))
((0, datetime.datetime(1517, 4, 1, 0, 0)), (1, datetime.datetime(1517, 12, 31, 0, 0)), (2, datetime.datetime(1517, 6, 30, 0, 0)))
IndexHourGO.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.IndexHourGO(('1517-04-01', '1517-12-31', '1517-06-30'))
>>> ix
<IndexHourGO>
1517-04-01T00
1517-12-31T00
1517-06-30T00
<datetime64[h]>
>>> ix.iter_label().apply_pool(lambda l: l.astype('<M8[ms]').astype(object).month, use_threads=True)
[ 4 12  6]

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