Detail: Quilt: Iterator

Overview: Quilt: Iterator

Quilt.iter_array(*, axis)
iter_array

Iterator of np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_array(axis=1))
(array([0, 1]), array([2, 3]), array([4, 5]), array([40, 41]), array([42, 43]), array([44, 45]))
Quilt.iter_array(*, axis).apply(func, *, dtype, name, index_constructor)
iter_array

Iterator of np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_array(axis=1).apply(lambda v: v.sum())
<Series>
<IndexHierarchy>
x                p     1
x                q     5
x                r     9
v                p     81
v                q     85
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_array(*, axis).apply_iter(func)
iter_array

Iterator of np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_array(axis=1).apply_iter(lambda v: v.sum()))
(1, 5, 9, 81, 85, 89)
Quilt.iter_array(*, axis).apply_iter_items(func)
iter_array

Iterator of np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_array(axis=1).apply_iter_items(lambda v: v.sum()))
((('x', 'p'), 1), (('x', 'q'), 5), (('x', 'r'), 9), (('v', 'p'), 81), (('v', 'q'), 85), (('v', 'r'), 89))
Quilt.iter_array(*, axis).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_array

Iterator of np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_array(axis=1).apply_pool(lambda v: v.sum(), use_threads=True)
<Series>
<IndexHierarchy>
x                p     1
x                q     5
x                r     9
v                p     81
v                q     85
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_array_items(*, axis)
iter_array_items

Iterator of pairs of label, np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_array_items(axis=1))
((('x', 'p'), array([0, 1])), (('x', 'q'), array([2, 3])), (('x', 'r'), array([4, 5])), (('v', 'p'), array([40, 41])), (('v', 'q'), array([42, 43])), (('v', 'r'), array([44, 45])))
Quilt.iter_array_items(*, axis).apply(func, *, dtype, name, index_constructor)
iter_array_items

Iterator of pairs of label, np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_array_items(axis=1).apply(lambda k, v: v.sum() if 'q' in k else -1)
<Series>
<IndexHierarchy>
x                p     -1
x                q     5
x                r     -1
v                p     -1
v                q     85
v                r     -1
<<U1>            <<U1> <int64>
Quilt.iter_array_items(*, axis).apply_iter(func)
iter_array_items

Iterator of pairs of label, np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_array_items(axis=1).apply_iter(lambda k, v: v.sum() if 'q' in k else -1))
(-1, 5, -1, -1, 85, -1)
Quilt.iter_array_items(*, axis).apply_iter_items(func)
iter_array_items

Iterator of pairs of label, np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_array_items(axis=1).apply_iter_items(lambda k, v: v.sum() if 'q' in k else -1))
((('x', 'p'), -1), (('x', 'q'), 5), (('x', 'r'), -1), (('v', 'p'), -1), (('v', 'q'), 85), (('v', 'r'), -1))
Quilt.iter_array_items(*, axis).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_array_items

Iterator of pairs of label, np.array, where arrays are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_array_items(axis=1).apply_pool(lambda pair: pair[1].sum() if pair[0][1] != 'p' else -1, use_threads=True)
<Series>
<IndexHierarchy>
x                p     -1
x                q     5
x                r     9
v                p     -1
v                q     85
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_series(*, axis)
iter_series

Iterator of Series, where Series are drawn from columns (axis=0) or rows (axis=1)

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_series(axis=1))
(<Series: ('x', 'p')>
<Index>
a                    0
b                    1
<<U1>                <int64>, <Series: ('x', 'q')>
<Index>
a                    2
b                    3
<<U1>                <int64>, <Series: ('x', 'r')>
<Index>
a                    4
b                    5
<<U1>                <int64>, <Series: ('v', 'p')>
<Index>
a                    40
b                    41
<<U1>                <int64>, <Series: ('v', 'q')>
<Index>
a                    42
b                    43
<<U1>                <int64>, <Series: ('v', 'r')>
<Index>
a                    44
b                    45
<<U1>                <int64>)
Quilt.iter_series(*, axis).apply(func, *, dtype, name, index_constructor)
iter_series

Iterator of Series, where Series are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_series(axis=1).apply(lambda v: v.sum())
<Series>
<IndexHierarchy>
x                p     1
x                q     5
x                r     9
v                p     81
v                q     85
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_series(*, axis).apply_iter(func)
iter_series

Iterator of Series, where Series are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_series(axis=1).apply_iter(lambda v: v.sum()))
(1, 5, 9, 81, 85, 89)
Quilt.iter_series(*, axis).apply_iter_items(func)
iter_series

Iterator of Series, where Series are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_series(axis=1).apply_iter_items(lambda v: v.sum()))
((('x', 'p'), 1), (('x', 'q'), 5), (('x', 'r'), 9), (('v', 'p'), 81), (('v', 'q'), 85), (('v', 'r'), 89))
Quilt.iter_series(*, axis).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_series

Iterator of Series, where Series are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_series(axis=1).apply_pool(lambda v: v.sum(), use_threads=True)
<Series>
<IndexHierarchy>
x                p     1
x                q     5
x                r     9
v                p     81
v                q     85
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_series_items(*, axis)
iter_series_items

Iterator of pairs of label, Series, where Series are drawn from columns (axis=0) or rows (axis=1)

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_series_items(axis=1))
((('x', 'p'), <Series: ('x', 'p')>
<Index>
a                    0
b                    1
<<U1>                <int64>), (('x', 'q'), <Series: ('x', 'q')>
<Index>
a                    2
b                    3
<<U1>                <int64>), (('x', 'r'), <Series: ('x', 'r')>
<Index>
a                    4
b                    5
<<U1>                <int64>), (('v', 'p'), <Series: ('v', 'p')>
<Index>
a                    40
b                    41
<<U1>                <int64>), (('v', 'q'), <Series: ('v', 'q')>
<Index>
a                    42
b                    43
<<U1>                <int64>), (('v', 'r'), <Series: ('v', 'r')>
<Index>
a                    44
b                    45
<<U1>                <int64>))
Quilt.iter_series_items(*, axis).apply(func, *, dtype, name, index_constructor)
iter_series_items

Iterator of pairs of label, Series, where Series are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_series_items(axis=1).apply(lambda k, v: v.sum() if 'q' in k else -1)
<Series>
<IndexHierarchy>
x                p     -1
x                q     5
x                r     -1
v                p     -1
v                q     85
v                r     -1
<<U1>            <<U1> <int64>
Quilt.iter_series_items(*, axis).apply_iter(func)
iter_series_items

Iterator of pairs of label, Series, where Series are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_series_items(axis=1).apply_iter(lambda k, v: v.sum() if 'q' in k else -1))
(-1, 5, -1, -1, 85, -1)
Quilt.iter_series_items(*, axis).apply_iter_items(func)
iter_series_items

Iterator of pairs of label, Series, where Series are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_series_items(axis=1).apply_iter_items(lambda k, v: v.sum() if 'q' in k else -1))
((('x', 'p'), -1), (('x', 'q'), 5), (('x', 'r'), -1), (('v', 'p'), -1), (('v', 'q'), 85), (('v', 'r'), -1))
Quilt.iter_series_items(*, axis).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_series_items

Iterator of pairs of label, Series, where Series are drawn from columns (axis=0) or rows (axis=1)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_series_items(axis=1).apply_pool(lambda pair: pair[1].sum() if pair[0][1] != 'p' else -1, use_threads=True)
<Series>
<IndexHierarchy>
x                p     -1
x                q     5
x                r     9
v                p     -1
v                q     85
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_tuple(*, axis, constructor)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple(axis=1))
(Axis(a=0, b=1), Axis(a=2, b=3), Axis(a=4, b=5), Axis(a=40, b=41), Axis(a=42, b=43), Axis(a=44, b=45))
Quilt.iter_tuple(*, axis, constructor).apply(func, *, dtype, name, index_constructor)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.apply(func, *, dtype=None, name=None, index_constructor=None)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_tuple(axis=1).apply(lambda v: v.a + v.b)
<Series>
<IndexHierarchy>
x                p     1
x                q     5
x                r     9
v                p     81
v                q     85
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_tuple(*, axis, constructor).apply_iter(func)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.apply_iter(func)

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

Parameters

func – A function that takes a value.

Yields

Values after function application.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple(axis=1).apply_iter(lambda v: v.a + v.b))
(1, 5, 9, 81, 85, 89)
Quilt.iter_tuple(*, axis, constructor).apply_iter_items(func)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.apply_iter_items(func)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple(axis=1).apply_iter_items(lambda v: v.a + v.b))
((('x', 'p'), 1), (('x', 'q'), 5), (('x', 'r'), 9), (('v', 'p'), 81), (('v', 'q'), 85), (('v', 'r'), 89))
Quilt.iter_tuple(*, axis, constructor).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.apply_pool(func, *, dtype=None, name=None, index_constructor=None, max_workers=None, chunksize=1, use_threads=False)

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.

Quilt.iter_tuple(*, axis, constructor).map_all(mapping, *, dtype, name, index_constructor)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_all(mapping, *, dtype=None, name=None, index_constructor=None)[source]

Apply a mapping; for values not in the mapping, an Exception is raised. Returns a new container.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

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

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iloc[:2].iter_tuple(axis=1).map_all({(0, 1): -1, (2, 3): -2})
<Series>
<IndexHierarchy>
x                p     -1
x                q     -2
<<U1>            <<U1> <int64>
Quilt.iter_tuple(*, axis, constructor).map_all_iter(mapping)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_all_iter(mapping)[source]

Apply a mapping; for values not in the mapping, an Exception is raised. A generator of resulting values.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iloc[:2].iter_tuple(axis=1).map_all_iter({(0, 1): -1, (2, 3): -2}))
(-1, -2)
Quilt.iter_tuple(*, axis, constructor).map_all_iter_items(mapping)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_all_iter_items(mapping)[source]

Apply a mapping; for values not in the mapping, an Exception is raised. A generator of resulting key, value pairs.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iloc[:2].iter_tuple(axis=1).map_all_iter_items({(0, 1): -1, (2, 3): -2}))
((('x', 'p'), -1), (('x', 'q'), -2))
Quilt.iter_tuple(*, axis, constructor).map_any(mapping, *, dtype, name, index_constructor)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_any(mapping, *, dtype=None, name=None, index_constructor=None)[source]

Apply a mapping; for values not in the mapping, the value is returned. Returns a new container.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

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

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_tuple(axis=1).map_any({(0, 1): -1, (42, 43): -2})
<Series>
<IndexHierarchy>
x                p     -1
x                q     Axis(a=2, b=3)
x                r     Axis(a=4, b=5)
v                p     Axis(a=40, b=41)
v                q     -2
v                r     Axis(a=44, b=45)
<<U1>            <<U1> <object>
Quilt.iter_tuple(*, axis, constructor).map_any_iter(mapping)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_any_iter(mapping)[source]

Apply a mapping; for values not in the mapping, the value is returned. A generator of resulting values.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple(axis=1).map_any_iter({(0, 1): -1, (42, 43): -2}))
(-1, Axis(a=2, b=3), Axis(a=4, b=5), Axis(a=40, b=41), -2, Axis(a=44, b=45))
Quilt.iter_tuple(*, axis, constructor).map_any_iter_items(mapping)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_any_iter_items(mapping)[source]

Apply a mapping; for values not in the mapping, the value is returned. A generator of resulting key, value pairs.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple(axis=1).map_any_iter_items({(0, 1): -1, (42, 43): -2}))
((('x', 'p'), -1), (('x', 'q'), Axis(a=2, b=3)), (('x', 'r'), Axis(a=4, b=5)), (('v', 'p'), Axis(a=40, b=41)), (('v', 'q'), -2), (('v', 'r'), Axis(a=44, b=45)))
Quilt.iter_tuple(*, axis, constructor).map_fill(mapping, *, fill_value, dtype, name, index_constructor)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_fill(mapping, *, fill_value=nan, dtype=None, name=None, index_constructor=None)[source]

Apply a mapping; for values not in the mapping, the fill_value is returned. Returns a new container.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

  • fill_value – Value to be returned if the values is not a key in the mapping.

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

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_tuple(axis=1).map_fill({(0, 1): -1, (42, 43): -2}, fill_value=np.nan)
<Series>
<IndexHierarchy>
x                p     -1.0
x                q     nan
x                r     nan
v                p     nan
v                q     -2.0
v                r     nan
<<U1>            <<U1> <float64>
Quilt.iter_tuple(*, axis, constructor).map_fill_iter(mapping, *, fill_value)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_fill_iter(mapping, *, fill_value=nan)[source]

Apply a mapping; for values not in the mapping, the fill_value is returned. A generator of resulting values.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

  • fill_value – Value to be returned if the values is not a key in the mapping.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple(axis=1).map_fill_iter({(0, 1): -1, (42, 43): -2}, fill_value=np.nan))
(-1, nan, nan, nan, -2, nan)
Quilt.iter_tuple(*, axis, constructor).map_fill_iter_items(mapping, *, fill_value)
iter_tuple

Iterator of NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1). An optional constructor callable can be used to provide a NamedTuple class (or any other constructor called with a single iterable) to be used to create each yielded axis value.

IterNodeDelegateMapable.map_fill_iter_items(mapping, *, fill_value=nan)[source]

Apply a mapping; for values not in the mapping, the fill_value is returned. A generator of resulting key, value pairs.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

  • fill_value – Value to be returned if the values is not a key in the mapping.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple(axis=1).map_fill_iter_items({(0, 1): -1, (42, 43): -2}, fill_value=np.nan))
((('x', 'p'), -1), (('x', 'q'), nan), (('x', 'r'), nan), (('v', 'p'), nan), (('v', 'q'), -2), (('v', 'r'), nan))
Quilt.iter_tuple_items(*, axis, constructor)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple_items(axis=1))
((('x', 'p'), Axis(a=0, b=1)), (('x', 'q'), Axis(a=2, b=3)), (('x', 'r'), Axis(a=4, b=5)), (('v', 'p'), Axis(a=40, b=41)), (('v', 'q'), Axis(a=42, b=43)), (('v', 'r'), Axis(a=44, b=45)))
Quilt.iter_tuple_items(*, axis, constructor).apply(func, *, dtype, name, index_constructor)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.apply(func, *, dtype=None, name=None, index_constructor=None)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_tuple_items(axis=1).apply(lambda k, v: v.a + v.b if 'r' in k else -1)
<Series>
<IndexHierarchy>
x                p     -1
x                q     -1
x                r     9
v                p     -1
v                q     -1
v                r     89
<<U1>            <<U1> <int64>
Quilt.iter_tuple_items(*, axis, constructor).apply_iter(func)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.apply_iter(func)

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

Parameters

func – A function that takes a value.

Yields

Values after function application.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple_items(axis=1).apply_iter(lambda k, v: v.a + v.b if 'r' in k else -1))
(-1, -1, 9, -1, -1, 89)
Quilt.iter_tuple_items(*, axis, constructor).apply_iter_items(func)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.apply_iter_items(func)

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple_items(axis=1).apply_iter_items(lambda k, v: v.a + v.b if 'r' in k else -1))
((('x', 'p'), -1), (('x', 'q'), -1), (('x', 'r'), 9), (('v', 'p'), -1), (('v', 'q'), -1), (('v', 'r'), 89))
Quilt.iter_tuple_items(*, axis, constructor).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.apply_pool(func, *, dtype=None, name=None, index_constructor=None, max_workers=None, chunksize=1, use_threads=False)

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.

Quilt.iter_tuple_items(*, axis, constructor).map_all(mapping, *, dtype, name, index_constructor)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_all(mapping, *, dtype=None, name=None, index_constructor=None)[source]

Apply a mapping; for values not in the mapping, an Exception is raised. Returns a new container.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

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

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iloc[:2].iter_tuple_items(axis=1).map_all({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2})
<Series>
<IndexHierarchy>
x                p     -1
x                q     -2
<<U1>            <<U1> <int64>
Quilt.iter_tuple_items(*, axis, constructor).map_all_iter(mapping)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_all_iter(mapping)[source]

Apply a mapping; for values not in the mapping, an Exception is raised. A generator of resulting values.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iloc[:2].iter_tuple_items(axis=1).map_all_iter({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2}))
(-1, -2)
Quilt.iter_tuple_items(*, axis, constructor).map_all_iter_items(mapping)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_all_iter_items(mapping)[source]

Apply a mapping; for values not in the mapping, an Exception is raised. A generator of resulting key, value pairs.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iloc[:2].iter_tuple_items(axis=1).map_all_iter_items({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2}))
((('x', 'p'), -1), (('x', 'q'), -2))
Quilt.iter_tuple_items(*, axis, constructor).map_any(mapping, *, dtype, name, index_constructor)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_any(mapping, *, dtype=None, name=None, index_constructor=None)[source]

Apply a mapping; for values not in the mapping, the value is returned. Returns a new container.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

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

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_tuple_items(axis=1).map_any({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2})
<Series>
<IndexHierarchy>
x                p     -1
x                q     -2
x                r     Axis(a=4, b=5)
v                p     Axis(a=40, b=41)
v                q     Axis(a=42, b=43)
v                r     Axis(a=44, b=45)
<<U1>            <<U1> <object>
Quilt.iter_tuple_items(*, axis, constructor).map_any_iter(mapping)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_any_iter(mapping)[source]

Apply a mapping; for values not in the mapping, the value is returned. A generator of resulting values.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple_items(axis=1).map_any_iter({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2}))
(-1, -2, Axis(a=4, b=5), Axis(a=40, b=41), Axis(a=42, b=43), Axis(a=44, b=45))
Quilt.iter_tuple_items(*, axis, constructor).map_any_iter_items(mapping)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_any_iter_items(mapping)[source]

Apply a mapping; for values not in the mapping, the value is returned. A generator of resulting key, value pairs.

Parameters

mapping – A mapping type, such as a dictionary or Series.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple_items(axis=1).map_any_iter_items({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2}))
((('x', 'p'), -1), (('x', 'q'), -2), (('x', 'r'), Axis(a=4, b=5)), (('v', 'p'), Axis(a=40, b=41)), (('v', 'q'), Axis(a=42, b=43)), (('v', 'r'), Axis(a=44, b=45)))
Quilt.iter_tuple_items(*, axis, constructor).map_fill(mapping, *, fill_value, dtype, name, index_constructor)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_fill(mapping, *, fill_value=nan, dtype=None, name=None, index_constructor=None)[source]

Apply a mapping; for values not in the mapping, the fill_value is returned. Returns a new container.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

  • fill_value – Value to be returned if the values is not a key in the mapping.

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

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_tuple_items(axis=1).map_fill({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2}, fill_value=np.nan)
<Series>
<IndexHierarchy>
x                p     -1.0
x                q     -2.0
x                r     nan
v                p     nan
v                q     nan
v                r     nan
<<U1>            <<U1> <float64>
Quilt.iter_tuple_items(*, axis, constructor).map_fill_iter(mapping, *, fill_value)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_fill_iter(mapping, *, fill_value=nan)[source]

Apply a mapping; for values not in the mapping, the fill_value is returned. A generator of resulting values.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

  • fill_value – Value to be returned if the values is not a key in the mapping.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple_items(axis=1).map_fill_iter({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2}, fill_value=np.nan))
(-1, -2, nan, nan, nan, nan)
Quilt.iter_tuple_items(*, axis, constructor).map_fill_iter_items(mapping, *, fill_value)
iter_tuple_items

Iterator of pairs of label, NamedTuple, where tuples are drawn from columns (axis=0) or rows (axis=1)

IterNodeDelegateMapable.map_fill_iter_items(mapping, *, fill_value=nan)[source]

Apply a mapping; for values not in the mapping, the fill_value is returned. A generator of resulting key, value pairs.

Parameters
  • mapping – A mapping type, such as a dictionary or Series.

  • fill_value – Value to be returned if the values is not a key in the mapping.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_tuple_items(axis=1).map_fill_iter_items({(('x', 'p'), (0, 1)): -1, (('x', 'q'), (2, 3)): -2}, fill_value=np.nan))
((('x', 'p'), -1), (('x', 'q'), -2), (('x', 'r'), nan), (('v', 'p'), nan), (('v', 'q'), nan), (('v', 'r'), nan))
Quilt.iter_window(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment)
iter_window

Iterator of windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window(size=2, step=2, axis=0))
(<Frame: x>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
<<U1>            <<U1> <int64> <int64>, <Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                r     4       5
v                p     40      41
<<U1>            <<U1> <int64> <int64>, <Frame: v>
<Index>                a       b       <<U1>
<IndexHierarchy>
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>)
Quilt.iter_window(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply(func, *, dtype, name, index_constructor)
iter_window

Iterator of windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_window(size=2, step=2, axis=0).apply(lambda f: f.max().max())
<Series>
<IndexHierarchy>
x                q     3
v                p     41
v                r     45
<<U1>            <<U1> <int64>
Quilt.iter_window(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter(func)
iter_window

Iterator of windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window(size=2, step=2, axis=0).apply_iter(lambda f: f.max().max()))
(3, 41, 45)
Quilt.iter_window(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter_items(func)
iter_window

Iterator of windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window(size=2, step=2, axis=0).apply_iter_items(lambda f: f.max().max()))
((('x', 'q'), 3), (('v', 'p'), 41), (('v', 'r'), 45))
Quilt.iter_window(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_window

Iterator of windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

Quilt.iter_window_array(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment)
iter_window_array

Iterator of windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_array(size=2, step=2, axis=0))
(array([[0, 1],
       [2, 3]]), array([[ 4,  5],
       [40, 41]]), array([[42, 43],
       [44, 45]]))
Quilt.iter_window_array(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply(func, *, dtype, name, index_constructor)
iter_window_array

Iterator of windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_window_array(size=2, step=2, axis=0).apply(lambda a: np.max(a))
<Series>
<IndexHierarchy>
x                q     3
v                p     41
v                r     45
<<U1>            <<U1> <int64>
Quilt.iter_window_array(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter(func)
iter_window_array

Iterator of windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_array(size=2, step=2, axis=0).apply_iter(lambda a: np.max(a)))
(3, 41, 45)
Quilt.iter_window_array(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter_items(func)
iter_window_array

Iterator of windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_array(size=2, step=2, axis=0).apply_iter_items(lambda a: np.max(a)))
((('x', 'q'), 3), (('v', 'p'), 41), (('v', 'r'), 45))
Quilt.iter_window_array(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_window_array

Iterator of windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

Quilt.iter_window_array_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment)
iter_window_array_items

Iterator of pairs of label, windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_array_items(size=2, step=2, axis=0))
((('x', 'q'), array([[0, 1],
       [2, 3]])), (('v', 'p'), array([[ 4,  5],
       [40, 41]])), (('v', 'r'), array([[42, 43],
       [44, 45]])))
Quilt.iter_window_array_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply(func, *, dtype, name, index_constructor)
iter_window_array_items

Iterator of pairs of label, windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_window_array_items(size=2, step=2, axis=0).apply(lambda k, v: np.max(v) if k == ('v', 'p') else np.min(v))
<Series>
<IndexHierarchy>
x                q     0
v                p     41
v                r     42
<<U1>            <<U1> <int64>
Quilt.iter_window_array_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter(func)
iter_window_array_items

Iterator of pairs of label, windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_array_items(size=2, step=2, axis=0).apply_iter(lambda k, v: np.max(v) if k == ('v', 'p') else np.min(v)))
(0, 41, 42)
Quilt.iter_window_array_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter_items(func)
iter_window_array_items

Iterator of pairs of label, windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_array_items(size=2, step=2, axis=0).apply_iter_items(lambda k, v: np.max(v) if k == ('v', 'p') else np.min(v)))
((('x', 'q'), 0), (('v', 'p'), 41), (('v', 'r'), 42))
Quilt.iter_window_array_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_window_array_items

Iterator of pairs of label, windowed values, where values are given as a np.array.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

Quilt.iter_window_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment)
iter_window_items

Iterator of pairs of label, windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_items(size=2, step=2, axis=0))
((('x', 'q'), <Frame: x>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
<<U1>            <<U1> <int64> <int64>), (('v', 'p'), <Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                r     4       5
v                p     40      41
<<U1>            <<U1> <int64> <int64>), (('v', 'r'), <Frame: v>
<Index>                a       b       <<U1>
<IndexHierarchy>
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>))
Quilt.iter_window_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply(func, *, dtype, name, index_constructor)
iter_window_items

Iterator of pairs of label, windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

IterNodeDelegate.apply(func, *, dtype=None, name=None, index_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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.iter_window_items(size=2, step=2, axis=0).apply(lambda k, v: v.max().max() if k == ('v', 'p') else v.min().min())
<Series>
<IndexHierarchy>
x                q     0
v                p     41
v                r     42
<<U1>            <<U1> <int64>
Quilt.iter_window_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter(func)
iter_window_items

Iterator of pairs of label, windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_items(size=2, step=2, axis=0).apply_iter(lambda k, v: v.max().max() if k == ('v', 'p') else v.min().min()))
(0, 41, 42)
Quilt.iter_window_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_iter_items(func)
iter_window_items

Iterator of pairs of label, windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q = sf.Quilt(b, retain_labels=True, axis=0)
>>> q
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> tuple(q.iter_window_items(size=2, step=2, axis=0).apply_iter_items(lambda k, v: v.max().max() if k == ('v', 'p') else v.min().min()))
((('x', 'q'), 0), (('v', 'p'), 41), (('v', 'r'), 42))
Quilt.iter_window_items(*, size, axis, step, window_sized, window_func, window_valid, label_shift, start_shift, size_increment).apply_pool(func, *, dtype, name, index_constructor, max_workers, chunksize, use_threads)
iter_window_items

Iterator of pairs of label, windowed values, where values are given as a Frame.

Parameters
  • size – Elements per window, given as an integer greater than 0.

  • axis – Integer specifying axis, where 0 is rows and 1 is columns. Axis 0 is set by default.

  • step – Element shift per window, given as an integer greater than 0. Determines the step size between windows. A step of 1 shifts each window 1 element; a step equal to the size will result in non-overlapping windows.

  • window_sized – if True, windows with fewer elements than size are skipped.

  • window_func – Array processor of window values, executed before function application (if used): can be used for applying a weighting function to each window.

  • window_valid – Function that, given an array window, returns True if the window is valid; invalid windows are skipped.

  • label_shift – A shift, relative to the right-most element contained in the window, to derive the label to be paired with the window. For example, to label each window with the label found at the start of the window, label_shift can be set to one less than size.

  • start_shift – A shift to determine the first element where window collection begins.

  • size_increment – A value to be added to size with each window after the first, so as to, in combination with setting step to 0, permit iterating over expanding windows.

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.

Quilt: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Iterator | Accessor Hashlib