Detail: Quilt: Method

Overview: Quilt: Method

Quilt.__bool__()

Raises ValueError to prohibit ambiguous use of truethy evaluation.

>>> 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)
>>> bool(b)
ValueError('The truth value of a container is ambiguous. For a truthy indicator of non-empty status, use the `size` attribute.')
Quilt.equals(other, *, compare_name=False, compare_dtype=False, compare_class=False, skipna=True)[source]

Return a bool from comparison to any other object.

Note: this will attempt to load and compare all Frame managed by the Bus stored within this Quilt.

Parameters
  • compare_name – Include equality of the container’s name (and all composed containers) in the comparison.

  • compare_dtype – Include equality of the container’s dtype (and all composed containers) in the comparison.

  • compare_class – Include equality of the container’s class (and all composed containers) in the comparison.

  • skipna – If True, comparisons between missing values are equal.

>>> 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')
>>> q1 = sf.Quilt(b, retain_labels=True, axis=0)
>>> q2 = sf.Quilt(b, retain_labels=True, axis=1)
>>> q1.equals(q2)
False
Quilt.head(count=5)[source]

Return a Quilt consisting only of the top elements as specified by count.

Parameters

count – Number of elements to be returned from the top of the Quilt

>>> 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.head(2)
<Frame: x>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
<<U1>            <<U1> <int64> <int64>
Quilt.rename(name)[source]

Return a new Quilt with an updated name attribute.

Parameters

name

>>> 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.rename('y')
<Quilt: y>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
Quilt.sample(index=None, columns=None, *, seed=None)[source]

Randomly (optionally made deterministic with a fixed seed) extract items from the container to return a subset of the container.

Parameters
  • index. (Number of labels to select from the) –

  • columns. (Number of labels to select from the) –

  • selection. (Initial state of random) –

>>> 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.sample(2, 2, seed=0).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                r     4       5
v                r     44      45
<<U1>            <<U1> <int64> <int64>
Quilt.tail(count=5)[source]

Return a Quilt consisting only of the bottom elements as specified by count.

Parameters

count – Number of elements to be returned from the bottom of the Quilt

>>> 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.tail(2)
<Frame: v>
<Index>                a       b       <<U1>
<IndexHierarchy>
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
Quilt.unpersist()[source]

For the Bus or Yarn contained in this object, replace all loaded Frame with FrameDeferred.

>>> b1 = 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')
>>> b1.to_zip_npz('/tmp/b.zip')
>>> b2 = sf.Bus.from_zip_npz('/tmp/b.zip')
>>> q = sf.Quilt(b2, retain_labels=True, axis=0)
>>> q.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
>>> q.status
<Frame>
<Index> loaded size      nbytes    shape    <<U6>
<Index>
x       True   6.0       48.0      (3, 2)
v       True   6.0       48.0      (3, 2)
<<U1>   <bool> <float64> <float64> <object>
>>> q.unpersist()
>>> q.status
<Frame>
<Index> loaded size      nbytes    shape    <<U6>
<Index>
x       False  nan       nan       None
v       False  nan       nan       None
<<U1>   <bool> <float64> <float64> <object>

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