Detail: Batch: Method

Overview: Batch: Method

Batch.__array__(dtype=None)

Support the __array__ interface, returning an array of values.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> tuple(bt.__array__())
(<Frame: x>
<Index>    a       b       <<U1>
<Index>
p          0       1
q          2       3
r          4       5
<<U1>      <int64> <int64>, <Frame: v>
<Index>    a       b       <<U1>
<Index>
p          40      41
q          42      43
r          44      45
<<U1>      <int64> <int64>)
Batch.__array_ufunc__(ufunc, method, *args, **kwargs)

Support for NumPy elements or arrays on the left hand of binary operators.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> (np.array((0.5, 0)) * bt).to_frame()
<Frame>
<Index>                a         b         <<U1>
<IndexHierarchy>
i                p     0.0       0.0
i                q     1.0       0.0
i                r     2.0       0.0
j                p     20.0      0.0
j                q     21.0      0.0
j                r     22.0      0.0
<<U1>            <<U1> <float64> <float64>
Batch.__bool__()

Raises ValueError to prohibit ambiguous use of truethy evaluation.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bool(bt)
ValueError('The truth value of a container is ambiguous. For a truthy indicator of non-empty status, use the `size` attribute.')
Batch.__round__(decimals=0)[source]

Return a Batch with contained Frame rounded to the given decimals. Negative decimals round to the left of the decimal point.

Parameters

decimals – number of decimals to round to.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), ('j', sf.Frame(np.arange(100, 106).reshape(3,2) / 3, index=('p', 'q', 'r'), columns=('a', 'b'), name='x'))))
>>> round(bt, 2).to_frame()
<Frame>
<Index>                a         b         <<U1>
<IndexHierarchy>
i                p     40.0      41.0
i                q     42.0      43.0
i                r     44.0      45.0
j                p     33.33     33.67
j                q     34.0      34.33
j                r     34.67     35.0
<<U1>            <<U1> <float64> <float64>
Batch.all(axis=0, skipna=True, out=None)

Logical and over values along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w'))))
>>> bt.all().to_frame()
<Frame>
<Index> c      d      <<U1>
<Index>
i       False  True
j       False  False
<<U1>   <bool> <bool>
Batch.any(axis=0, skipna=True, out=None)

Logical or over values along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w'))))
>>> bt.any().to_frame()
<Frame>
<Index> c      d      <<U1>
<Index>
i       False  True
j       True   True
<<U1>   <bool> <bool>
Batch.apply(func)[source]

Apply a function to each Frame contained in this Frame, where a function is given the Frame as an argument.

>>> bt = sf.Batch((('i', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w'))))
>>> bt.apply(lambda f: f.iter_element().apply(lambda e: '+' if e else '-')).to_frame()
<Frame>
<Index>                c     d     <<U1>
<IndexHierarchy>
i                p     -     +
i                q     -     +
i                r     -     +
j                p     -     +
j                q     +     -
j                r     +     +
<<U1>            <<U1> <<U1> <<U1>
Batch.apply_except(func, exception)[source]

Apply a function to each Frame contained in this Frame, where a function is given the Frame as an argument. Exceptions raised that matching the except argument will be silenced.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.apply_except(lambda f: f + 100, Exception).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                p     100     101
i                q     102     103
i                r     104     105
<<U1>            <<U1> <int64> <int64>
Batch.apply_items(func)[source]

Apply a function to each Frame contained in this Frame, where a function is given the pair of label, Frame as an argument.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.apply_items(lambda l, f: f * 100 if l == 'j' else f * 0.001).to_frame()
<Frame>
<Index>                a         b         <<U1>
<IndexHierarchy>
i                p     0.0       0.001
i                q     0.002     0.003
i                r     0.004     0.005
j                p     4000.0    4100.0
j                q     4200.0    4300.0
j                r     4400.0    4500.0
<<U1>            <<U1> <float64> <float64>
Batch.apply_items_except(func, exception)[source]

Apply a function to each Frame contained in this Frame, where a function is given the pair of label, Frame as an argument. Exceptions raised that matching the except argument will be silenced.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.apply_items_except(lambda l, f: f * 100 if l == 'j' else f * 0.001, Exception).to_frame()
<Frame>
<Index>                a         b         <<U1>
<IndexHierarchy>
i                p     0.0       0.001
i                q     0.002     0.003
i                r     0.004     0.005
<<U1>            <<U1> <float64> <float64>
Batch.astype[key](dtypes, *, consolidate_blocks)
Batch.astype

Return a new Batch with astype transformed.

InterfaceBatchAsType.__getitem__(key)[source]

Selector of columns by label.

Parameters

key – A loc selector, either a label, a list of labels, a slice of labels, or a Boolean array.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.astype['a'](str).to_frame()
<Frame>
<Index>                a      b       <<U1>
<IndexHierarchy>
i                p     0      1
i                q     2      3
i                r     4      5
j                p     40     41
j                q     42     43
j                r     44     45
<<U1>            <<U1> <<U21> <int64>
Batch.astype(dtype)
astype

Return a new Batch with astype transformed.

InterfaceBatchAsType.__call__(dtype)[source]

Apply a single dtype to all columns.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.astype(str).to_frame()
<Frame>
<Index>                a      b      <<U1>
<IndexHierarchy>
i                p     0      1
i                q     2      3
i                r     4      5
j                p     40     41
j                q     42     43
j                r     44     45
<<U1>            <<U1> <<U21> <<U21>
Batch.clip(*, lower=None, upper=None, axis=None)[source]

Apply a clip operation to this Batch. Note that clip operations can be applied to object types, but cannot be applied to non-numerical objects (e.g., strings, None)

Parameters
>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.clip(lower=3, upper=41).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                p     3       3
i                q     3       3
i                r     4       5
j                p     40      41
j                q     41      41
j                r     41      41
<<U1>            <<U1> <int64> <int64>
Batch.corr(*, axis=1)[source]

Compute a correlation matrix.

Parameters

axis – if 0, each row represents a variable, with observations as columns; if 1, each column represents a variable, with observations as rows. Defaults to 1.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), ('j', sf.Frame(np.arange(100, 106).reshape(3,2) / 3, index=('p', 'q', 'r'), columns=('a', 'b'), name='x'))))
>>> bt.corr().to_frame()
<Frame>
<Index>                a         b         <<U1>
<IndexHierarchy>
i                a     1.0       1.0
i                b     1.0       1.0
j                a     1.0       1.0
j                b     1.0       1.0
<<U1>            <<U1> <float64> <float64>
Batch.count(*, skipna=True, skipfalsy=False, unique=False, axis=0)[source]

Apply count on contained Frames.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.count(skipna=True).to_frame()
<Frame>
<Index> a       b       <<U1>
<Index>
i       3       3
j       3       3
<<U1>   <int64> <int64>
>>> bt.count(unique=True).to_frame()
<Frame>
<Index> a       b       <<U1>
<Index>
i       3       3
j       3       3
<<U1>   <int64> <int64>
Batch.cov(*, axis=1, ddof=1)[source]

Compute a covariance matrix.

Parameters
  • axis – if 0, each row represents a variable, with observations as columns; if 1, each column represents a variable, with observations as rows. Defaults to 1.

  • ddof – Delta degrees of freedom, defaults to 1.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), ('j', sf.Frame(np.arange(100, 106).reshape(3,2) / 3, index=('p', 'q', 'r'), columns=('a', 'b'), name='x'))))
>>> bt.cov().to_frame()
<Frame>
<Index>                a                   b                   <<U1>
<IndexHierarchy>
i                a     4.0                 4.0
i                b     4.0                 4.0
j                a     0.4444444444444413  0.44444444444444364
j                b     0.44444444444444364 0.44444444444444603
<<U1>            <<U1> <float64>           <float64>
Batch.cumprod(axis=0, skipna=True)

Return the cumulative product over the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), ('j', sf.Frame(np.arange(100, 106).reshape(3,2) / 3, index=('p', 'q', 'r'), columns=('a', 'b'), name='x'))))
>>> bt.cumprod().to_frame()
<Frame>
<Index>                a                  b                  <<U1>
<IndexHierarchy>
i                p     40.0               41.0
i                q     1680.0             1763.0
i                r     73920.0            79335.0
j                p     33.333333333333336 33.666666666666664
j                q     1133.3333333333335 1155.888888888889
j                r     39288.88888888889  40456.11111111111
<<U1>            <<U1> <float64>          <float64>
Batch.cumsum(axis=0, skipna=True)

Return the cumulative sum over the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), ('j', sf.Frame(np.arange(100, 106).reshape(3,2) / 3, index=('p', 'q', 'r'), columns=('a', 'b'), name='x'))))
>>> bt.cumsum().to_frame()
<Frame>
<Index>                a                  b                  <<U1>
<IndexHierarchy>
i                p     40.0               41.0
i                q     82.0               84.0
i                r     126.0              129.0
j                p     33.333333333333336 33.666666666666664
j                q     67.33333333333334  68.0
j                r     102.0              103.0
<<U1>            <<U1> <float64>          <float64>
Batch.drop_duplicated(*, axis=0, exclude_first=False, exclude_last=False)[source]

Return a Batch with contained Frame with duplicated rows (axis 0) or columns (axis 1) removed. All values in the row or column are compared to determine duplication.

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

  • exclude_first – Boolean to select if the first duplicated value is excluded.

  • exclude_last – Boolean to select if the last duplicated value is excluded.

>>> bt = sf.Batch((('i', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w'))))
>>> bt.drop_duplicated().to_frame()
<Frame>
<Index>                c      d      <<U1>
<IndexHierarchy>
j                p     False  True
j                q     True   False
j                r     True   True
<<U1>            <<U1> <bool> <bool>
Batch.dropfalsy(axis=0, condition=<function all>)[source]

Return a Batch with contained Frame after removing rows (axis 0) or columns (axis 1) where any or all values are NA (NaN or None). The condition is determined by a NumPy ufunc that process the Boolean array returned by isna(); the default is np.all.

Parameters
  • axis

  • condition

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.dropfalsy(condition=np.any, axis=0).to_frame()
<Frame>
<Index>                   a         b        c          <<U1>
<IndexHierarchy>
i                q        2.0       3        nan
i                r        4.0       5        nan
j                0        10.0      qrs      1517-01-01
j                1        2.0       XYZ      1517-04-01
j                3        2.0       123      1517-04-01
<<U1>            <object> <float64> <object> <object>
Batch.dropna(axis=0, condition=<function all>)[source]

Return a Batch with contained Frame after removing rows (axis 0) or columns (axis 1) where any or all values are NA (NaN or None). The condition is determined by a NumPy ufunc that process the Boolean array returned by isna(); the default is np.all.

Parameters
  • axis

  • condition

>>> bt = sf.Batch((('i', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w'))))
>>> bt.dropna().to_frame()
<Frame>
<Index>                c      d      <<U1>
<IndexHierarchy>
i                p     False  True
i                q     False  True
i                r     False  True
j                p     False  True
j                q     True   False
j                r     True   True
<<U1>            <<U1> <bool> <bool>
Batch.duplicated(*, axis=0, exclude_first=False, exclude_last=False)[source]

Return an axis-sized Boolean Series that shows True for all rows (axis 0) or columns (axis 1) duplicated.

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

  • exclude_first – Boolean to select if the first duplicated value is excluded.

  • exclude_last – Boolean to select if the last duplicated value is excluded.

>>> bt = sf.Batch((('i', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w'))))
>>> bt.duplicated().to_frame()
<Frame>
<Index> p      q      r      <<U1>
<Index>
i       True   True   True
j       False  False  False
<<U1>   <bool> <bool> <bool>
Batch.equals(other, *, compare_name=False, compare_dtype=False, compare_class=False, skipna=True)
>>> bt1 = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt2 = sf.Batch((('i', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), ('j', sf.Frame(np.arange(100, 106).reshape(3,2) / 3, index=('p', 'q', 'r'), columns=('a', 'b'), name='x'))))
>>> bt1.equals(bt2)
NotImplementedError()
Batch.fillfalsy(value)[source]

Return a new Batch with contained Frame after filling falsy values with the provided value.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.fillfalsy([-1, '', np.nan]).to_frame()
<Frame>
<Index>                   a         b        c          <<U1>
<IndexHierarchy>
i                p        -1.0      1        nan
i                q        2.0       3        nan
i                r        4.0       5        nan
j                0        10.0      qrs      1517-01-01
j                1        2.0       XYZ      1517-04-01
j                2        -1.0               nan
j                3        2.0       123      1517-04-01
<<U1>            <object> <float64> <object> <object>
Batch.fillfalsy_backward(limit=0, *, axis=0)[source]

Return a new Batch with contained Frame after filling backward falsy values with the first observed value.

Parameters
  • {limit}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillfalsy_backward().to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       nan
i                2       nan       8.0       nan
i                3       nan       nan       nan
j                0       10.0      8.0       1.0
j                1       10.0      8.0       1.0
j                2       10.0      3.0       1.0
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.fillfalsy_forward(limit=0, axis=0)[source]

Return a new Batch with contained Frame after filling forward falsy values with the last observed value.

Parameters
  • {limit}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillfalsy_forward().to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       1.0
i                2       2.0       8.0       1.0
i                3       2.0       8.0       1.0
j                0       nan       nan       nan
j                1       nan       8.0       nan
j                2       10.0      3.0       nan
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.fillfalsy_leading(value, *, axis=0)[source]

Return a new Batch with contained Frame after filling leading (and only leading) falsy values with the provided value.

Parameters
  • {value}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillfalsy_leading(-1).to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       nan
i                2       nan       8.0       nan
i                3       nan       nan       nan
j                0       -1.0      -1.0      -1.0
j                1       -1.0      8.0       -1.0
j                2       10.0      3.0       -1.0
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.fillfalsy_trailing(value, *, axis=0)[source]

Return a new Batch with contained Frame after filling trailing (and only trailing) falsy values with the provided value.

Parameters
  • {value}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillfalsy_trailing(-1).to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       -1.0
i                2       -1.0      8.0       -1.0
i                3       -1.0      -1.0      -1.0
j                0       nan       nan       nan
j                1       nan       8.0       nan
j                2       10.0      3.0       nan
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.fillna(value)[source]

Return a new Batch with contained Frame after filling null (NaN or None) with the provided value.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.fillna(-1).to_frame()
<Frame>
<Index>                   a         b        c          <<U1>
<IndexHierarchy>
i                p        0.0       1        nan
i                q        2.0       3        nan
i                r        4.0       5        nan
j                0        10.0      qrs      1517-01-01
j                1        2.0       XYZ      1517-04-01
j                2        -1.0               -1
j                3        2.0       123      1517-04-01
<<U1>            <object> <float64> <object> <object>
Batch.fillna_backward(limit=0, *, axis=0)[source]

Return a new Batch with contained Frame after filling backward null (NaN or None) with the first observed value.

Parameters
  • {limit}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillna_backward().to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       nan
i                2       nan       8.0       nan
i                3       nan       nan       nan
j                0       10.0      8.0       1.0
j                1       10.0      8.0       1.0
j                2       10.0      3.0       1.0
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.fillna_forward(limit=0, *, axis=0)[source]

Return a new Batch with contained Frame after filling forward null (NaN or None) with the last observed value.

Parameters
  • {limit}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillna_forward().to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       1.0
i                2       2.0       8.0       1.0
i                3       2.0       8.0       1.0
j                0       nan       nan       nan
j                1       nan       8.0       nan
j                2       10.0      3.0       nan
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.fillna_leading(value, *, axis=0)[source]

Return a new Batch with contained Frame after filling leading (and only leading) null (NaN or None) with the provided value.

Parameters
  • {value}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillna_leading(-1).to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       nan
i                2       nan       8.0       nan
i                3       nan       nan       nan
j                0       -1.0      -1.0      -1.0
j                1       -1.0      8.0       -1.0
j                2       10.0      3.0       -1.0
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.fillna_trailing(value, *, axis=0)[source]

Return a new Batch with contained Frame after filling trailing (and only trailing) null (NaN or None) with the provided value.

Parameters
  • {value}

  • {axis}

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.fillna_trailing(-1).to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       10.0      8.0       1.0
i                1       2.0       3.0       -1.0
i                2       -1.0      8.0       -1.0
i                3       -1.0      -1.0      -1.0
j                0       nan       nan       nan
j                1       nan       8.0       nan
j                2       10.0      3.0       nan
j                3       2.0       8.0       1.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.head(count=5)[source]

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

Parameters

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

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.head(2).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                p     0       1
i                q     2       3
j                p     40      41
j                q     42      43
<<U1>            <<U1> <int64> <int64>
Batch.iloc_max(*, skipna=True, axis=0)[source]

Return the integer indices corresponding to the maximum values found.

Parameters
  • skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

  • axis – Axis upon which to evaluate contiguous missing values, where 0 is vertically (between row values) and 1 is horizontally (between column values).

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.iloc_max().to_frame()
<Frame>
<Index> a       b       c       <<U1>
<Index>
i       0       0       0
j       2       1       3
<<U1>   <int64> <int64> <int64>
Batch.iloc_min(*, skipna=True, axis=0)[source]

Return the integer indices corresponding to the minimum values found.

Parameters
  • skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

  • axis – Axis upon which to evaluate contiguous missing values, where 0 is vertically (between row values) and 1 is horizontally (between column values).

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.iloc_min().to_frame()
<Frame>
<Index> a       b       c       <<U1>
<Index>
i       1       1       0
j       3       2       3
<<U1>   <int64> <int64> <int64>
Batch.isfalsy()[source]

Return a Batch with contained, same-indexed Frame indicating True which values are Falsy.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.isfalsy().to_frame(fill_value=False)
<Frame>
<Index>                   a      b      c      <<U1>
<IndexHierarchy>
i                p        True   False  False
i                q        False  False  False
i                r        False  False  False
j                0        False  False  False
j                1        False  False  False
j                2        True   True   True
j                3        False  False  False
<<U1>            <object> <bool> <bool> <bool>
Batch.isin(other)[source]

Return a new Batch with contained Frame as a same-sized Boolean Frame that shows if the same-positioned element is in the passed iterable.

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.isin((3, 10)).to_frame()
<Frame>
<Index>                  a      b      c      <<U1>
<IndexHierarchy>
i                0       True   False  False
i                1       False  True   False
i                2       False  False  False
i                3       False  False  False
j                0       False  False  False
j                1       False  False  False
j                2       True   True   False
j                3       False  False  False
<<U1>            <int64> <bool> <bool> <bool>
Batch.isna()[source]

Return a Batch with contained, same-indexed Frame indicating True which values are NaN or None.

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.isna().to_frame()
<Frame>
<Index>                  a      b      c      <<U1>
<IndexHierarchy>
i                0       False  False  False
i                1       False  False  True
i                2       True   False  True
i                3       True   True   True
j                0       True   True   True
j                1       True   False  True
j                2       False  False  True
j                3       False  False  False
<<U1>            <int64> <bool> <bool> <bool>
Batch.loc_max(*, skipna=True, axis=0)[source]

Return the labels corresponding to the maximum values found.

Parameters
  • skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

  • axis – Axis upon which to evaluate contiguous missing values, where 0 is vertically (between row values) and 1 is horizontally (between column values).

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.loc_max().to_frame()
<Frame>
<Index> a       b       c       <<U1>
<Index>
i       0       0       0
j       2       1       3
<<U1>   <int64> <int64> <int64>
Batch.loc_min(*, skipna=True, axis=0)[source]

Return the labels corresponding to the minimum value found.

Parameters
  • skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

  • axis – Axis upon which to evaluate contiguous missing values, where 0 is vertically (between row values) and 1 is horizontally (between column values).

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.loc_min().to_frame()
<Frame>
<Index> a       b       c       <<U1>
<Index>
i       1       1       0
j       3       2       3
<<U1>   <int64> <int64> <int64>
Batch.max(axis=0, skipna=True)

Return the maximum along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.max().to_frame()
<Frame>
<Index> a       b       <<U1>
<Index>
i       4       5
j       44      45
<<U1>   <int64> <int64>
Batch.mean(axis=0, skipna=True, out=None)

Return the mean along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.mean().to_frame()
<Frame>
<Index> a         b         <<U1>
<Index>
i       2.0       3.0
j       42.0      43.0
<<U1>   <float64> <float64>
Batch.median(axis=0, skipna=True, out=None)

Return the median along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.median().to_frame()
<Frame>
<Index> a         b         <<U1>
<Index>
i       2.0       3.0
j       42.0      43.0
<<U1>   <float64> <float64>
Batch.min(axis=0, skipna=True, out=None)

Return the minimum along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.min().to_frame()
<Frame>
<Index> a       b       <<U1>
<Index>
i       0       1
j       40      41
<<U1>   <int64> <int64>
Batch.notfalsy()[source]

Return a Batch with contained, same-indexed Frame indicating True which values are not Falsy.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.notfalsy().to_frame(fill_value=False)
<Frame>
<Index>                   a      b      c      <<U1>
<IndexHierarchy>
i                p        False  True   False
i                q        True   True   False
i                r        True   True   False
j                0        True   True   True
j                1        True   True   True
j                2        False  False  False
j                3        True   True   True
<<U1>            <object> <bool> <bool> <bool>
Batch.notna()[source]

Return a Batch with contained, same-indexed Frame indicating True which values are not NaN or None.

>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, np.nan, np.nan), (8, 3, 8, np.nan), (1, np.nan, np.nan, np.nan)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((np.nan, np.nan, 10, 2), (np.nan, 8, 3, 8), (np.nan, np.nan, np.nan, 1)), columns=('a', 'b', 'c'), name='y'))))
>>> bt.notna().to_frame()
<Frame>
<Index>                  a      b      c      <<U1>
<IndexHierarchy>
i                0       True   True   True
i                1       True   True   False
i                2       False  True   False
i                3       False  False  False
j                0       False  False  False
j                1       False  True   False
j                2       True   True   False
j                3       True   True   True
<<U1>            <int64> <bool> <bool> <bool>
Batch.prod(axis=0, skipna=True, out=None)

Return the product along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.prod().to_frame()
<Frame>
<Index> a       b       <<U1>
<Index>
i       0       15
j       73920   79335
<<U1>   <int64> <int64>
Batch.rank_dense(*, axis=0, skipna=True, ascending=True, start=0, fill_value=nan)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((11, 4, 10, 2), (0, 8, 3, 8), (0, 1, 0, 1)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((0, 0, 10, 2), (20, 18, -3, 18), (0, 0, 0, 1)), columns=('a', 'b', 'c'), name='x'))))
>>> bt.rank_dense().to_frame()
<Frame>
<Index>                  a       b       c       <<U1>
<IndexHierarchy>
i                0       3       0       0
i                1       1       2       1
i                2       2       1       0
i                3       0       2       1
j                0       0       2       0
j                1       0       1       0
j                2       2       0       0
j                3       1       1       1
<<U1>            <int64> <int64> <int64> <int64>
Batch.rank_max(*, axis=0, skipna=True, ascending=True, start=0, fill_value=nan)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((11, 4, 10, 2), (0, 8, 3, 8), (0, 1, 0, 1)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((0, 0, 10, 2), (20, 18, -3, 18), (0, 0, 0, 1)), columns=('a', 'b', 'c'), name='x'))))
>>> bt.rank_max().to_frame()
<Frame>
<Index>                  a       b       c       <<U1>
<IndexHierarchy>
i                0       3       0       1
i                1       1       3       3
i                2       2       1       1
i                3       0       3       3
j                0       1       3       2
j                1       1       2       2
j                2       3       0       2
j                3       2       2       3
<<U1>            <int64> <int64> <int64> <int64>
Batch.rank_mean(*, axis=0, skipna=True, ascending=True, start=0, fill_value=nan)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((11, 4, 10, 2), (0, 8, 3, 8), (0, 1, 0, 1)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((0, 0, 10, 2), (20, 18, -3, 18), (0, 0, 0, 1)), columns=('a', 'b', 'c'), name='x'))))
>>> bt.rank_mean().to_frame()
<Frame>
<Index>                  a         b         c         <<U1>
<IndexHierarchy>
i                0       3.0       0.0       0.5
i                1       1.0       2.5       2.5
i                2       2.0       1.0       0.5
i                3       0.0       2.5       2.5
j                0       0.5       3.0       1.0
j                1       0.5       1.5       1.0
j                2       3.0       0.0       1.0
j                3       2.0       1.5       3.0
<<U1>            <int64> <float64> <float64> <float64>
Batch.rank_min(*, axis=0, skipna=True, ascending=True, start=0, fill_value=nan)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((11, 4, 10, 2), (0, 8, 3, 8), (0, 1, 0, 1)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((0, 0, 10, 2), (20, 18, -3, 18), (0, 0, 0, 1)), columns=('a', 'b', 'c'), name='x'))))
>>> bt.rank_min().to_frame()
<Frame>
<Index>                  a       b       c       <<U1>
<IndexHierarchy>
i                0       3       0       0
i                1       1       2       2
i                2       2       1       0
i                3       0       2       2
j                0       0       3       0
j                1       0       1       0
j                2       3       0       0
j                3       2       1       3
<<U1>            <int64> <int64> <int64> <int64>
Batch.rank_ordinal(*, axis=0, skipna=True, ascending=True, start=0, fill_value=nan)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((11, 4, 10, 2), (0, 8, 3, 8), (0, 1, 0, 1)), columns=('a', 'b', 'c'), name='x')), ('j', sf.Frame.from_fields(((0, 0, 10, 2), (20, 18, -3, 18), (0, 0, 0, 1)), columns=('a', 'b', 'c'), name='x'))))
>>> bt.rank_ordinal().to_frame()
<Frame>
<Index>                  a       b       c       <<U1>
<IndexHierarchy>
i                0       3       0       0
i                1       1       2       2
i                2       2       1       1
i                3       0       3       3
j                0       0       3       0
j                1       1       1       1
j                2       3       0       2
j                3       2       2       3
<<U1>            <int64> <int64> <int64> <int64>
Batch.reindex(index=None, columns=None, *, fill_value=nan, own_index=False, own_columns=False, check_equals=True)[source]
>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.reindex(('q', 'p', 'a'), fill_value=sf.FillValueAuto).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                q     2       3
i                p     0       1
i                a     0       0
j                q     42      43
j                p     40      41
j                a     0       0
<<U1>            <<U1> <int64> <int64>
Batch.relabel(index=None, columns=None, *, index_constructor=None, columns_constructor=None)[source]
>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.relabel({'q':'x', 'p':'y', 0:'x', 1:'y'}).to_frame()
<Frame>
<Index>                   a         b        c          <<U1>
<IndexHierarchy>
i                y        0.0       1        nan
i                x        2.0       3        nan
i                r        4.0       5        nan
j                x        10.0      qrs      1517-01-01
j                y        2.0       XYZ      1517-04-01
j                2        nan                None
j                3        2.0       123      1517-04-01
<<U1>            <object> <float64> <object> <object>
>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame.from_fields(((10, 2, np.nan, 2), ('qrs ', 'XYZ', '', '123'), ('1517-01-01', '1517-04-01', 'NaT', '1517-04-01')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.relabel(lambda l: f'+{str(l).upper()}+').to_frame()
<Frame>
<Index>                a         b        c          <<U1>
<IndexHierarchy>
i                +P+   0.0       1        nan
i                +Q+   2.0       3        nan
i                +R+   4.0       5        nan
j                +0+   10.0      qrs      1517-01-01
j                +1+   2.0       XYZ      1517-04-01
j                +2+   nan                None
j                +3+   2.0       123      1517-04-01
<<U1>            <<U3> <float64> <object> <object>
Batch.relabel_flat(index=False, columns=False)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')), ('j', sf.Frame.from_fields(((23, 83, 19, 87), (True, True, False, False), ('2022-01-01', '2023-04-01', '2022-12-31', '2024-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.relabel_flat(index=True).to_frame()
<Frame>
<Index>                   a       b      c               <<U1>
<IndexHierarchy>
i                (0, 'p') 10      False  1517-01-01
i                (0, 'q') 2       True   1517-04-01
i                (1, 'p') 8       True   1517-12-31
i                (1, 'q') 3       False  1517-06-30
j                (0, 'p') 23      True   2022-01-01
j                (0, 'q') 83      True   2023-04-01
j                (1, 'p') 19      False  2022-12-31
j                (1, 'q') 87      False  2024-06-30
<<U1>            <object> <int64> <bool> <datetime64[D]>
Batch.relabel_level_add(index=None, columns=None, *, index_constructor=None, columns_constructor=None)[source]
>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> tuple(bt.relabel_level_add('I').values)
(<Frame: x>
<Index>                a       b       <<U1>
<IndexHierarchy>
I                p     0       1
I                q     2       3
I                r     4       5
<<U1>            <<U1> <int64> <int64>, <Frame: v>
<Index>                a       b       <<U1>
<IndexHierarchy>
I                p     40      41
I                q     42      43
I                r     44      45
<<U1>            <<U1> <int64> <int64>)
Batch.relabel_level_drop(index=0, columns=0)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')), ('j', sf.Frame.from_fields(((23, 83, 19, 87), (True, True, False, False), ('2022-01-01', '2023-04-01', '2022-12-31', '2024-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.iloc[:2].relabel_level_drop(1).to_frame()
<Frame>
<Index>                a       b      c               <<U1>
<IndexHierarchy>
i                p     10      False  1517-01-01
i                q     2       True   1517-04-01
j                p     23      True   2022-01-01
j                q     83      True   2023-04-01
<<U1>            <<U1> <int64> <bool> <datetime64[D]>
Batch.relabel_shift_in(key, *, axis=0)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')), ('j', sf.Frame.from_fields(((23, 83, 19, 87), (True, True, False, False), ('2022-01-01', '2023-04-01', '2022-12-31', '2024-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> tuple(bt.relabel_shift_in('a').values)
(<Frame: x>
<Index>                                            b      c               <<U1>
<IndexHierarchy: ('__index0__', '...
0                                    p     10      False  1517-01-01
0                                    q     2       True   1517-04-01
1                                    p     8       True   1517-12-31
1                                    q     3       False  1517-06-30
<int64>                              <<U1> <int64> <bool> <datetime64[D]>, <Frame: x>
<Index>                                            b      c               <<U1>
<IndexHierarchy: ('__index0__', '...
0                                    p     23      True   2022-01-01
0                                    q     83      True   2023-04-01
1                                    p     19      False  2022-12-31
1                                    q     87      False  2024-06-30
<int64>                              <<U1> <int64> <bool> <datetime64[D]>)
Batch.rename(name=<object object>, *, index=<object object>, columns=<object object>)[source]

Return a new Batch with an updated name attribute.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.rename('y').to_bus()
<Bus>
<Index>
i       Frame
j       Frame
<<U1>   <object>
Batch.roll(index=0, columns=0, *, include_index=False, include_columns=False)[source]

Roll columns and/or rows by positive or negative integer counts, where columns and/or rows roll around the axis.

Parameters
  • include_index – Determine if index is included in index-wise rotation.

  • include_columns – Determine if column index is included in index-wise rotation.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.roll(1, include_index=True).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                r     4       5
i                p     0       1
i                q     2       3
j                r     44      45
j                p     40      41
j                q     42      43
<<U1>            <<U1> <int64> <int64>
Batch.sample(index=None, columns=None, *, seed=None)[source]

Apply sample on contained Frames.

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

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

  • selection. (Initial state of random) –

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.sample(2, 2, seed=0).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                q     2       3
i                r     4       5
j                q     42      43
j                r     44      45
<<U1>            <<U1> <int64> <int64>
Batch.shift(index=0, columns=0, fill_value=nan)[source]

Shift columns and/or rows by positive or negative integer counts, where columns and/or rows fall of the axis and introduce missing values, filled by fill_value.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.shift(1, fill_value=sf.FillValueAuto).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                p     0       0
i                q     0       1
i                r     2       3
j                p     0       0
j                q     40      41
j                r     42      43
<<U1>            <<U1> <int64> <int64>
Batch.sort_columns(*, ascending=True, kind='mergesort')[source]

Return a new Batch with contained Frame ordered by the sorted columns.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.sort_columns(ascending=False).to_frame()
<Frame>
<Index>                b       a       <<U1>
<IndexHierarchy>
i                p     1       0
i                q     3       2
i                r     5       4
j                p     41      40
j                q     43      42
j                r     45      44
<<U1>            <<U1> <int64> <int64>
Batch.sort_index(*, ascending=True, kind='mergesort')[source]

Return a new Batch with contained :obj;`Frame` ordered by the sorted index.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.sort_index(ascending=False).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                r     4       5
i                q     2       3
i                p     0       1
j                r     44      45
j                q     42      43
j                p     40      41
<<U1>            <<U1> <int64> <int64>
Batch.sort_values(label, *, ascending=True, axis=1, kind='mergesort')[source]

Return a new Batch with contained Frame ordered by the sorted values, where values are given by single column or iterable of columns.

Parameters

label – a label or iterable of keys.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.sort_values('a', ascending=False).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                r     4       5
i                q     2       3
i                p     0       1
j                r     44      45
j                q     42      43
j                p     40      41
<<U1>            <<U1> <int64> <int64>
Batch.std(axis=0, skipna=True, ddof=0, out=None)

Return the standard deviaton along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.std().to_frame()
<Frame>
<Index> a                 b                 <<U1>
<Index>
i       1.632993161855452 1.632993161855452
j       1.632993161855452 1.632993161855452
<<U1>   <float64>         <float64>
Batch.sum(axis=0, skipna=True, out=None)

Sum values along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.sum().to_frame()
<Frame>
<Index> a       b       <<U1>
<Index>
i       6       9
j       126     129
<<U1>   <int64> <int64>
Batch.tail(count=5)[source]

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

Parameters

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

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.tail(2).to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
i                q     2       3
i                r     4       5
j                q     42      43
j                r     44      45
<<U1>            <<U1> <int64> <int64>
Batch.transpose()[source]

Transpose. Return a Frame with index as columns and vice versa.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.transpose().to_frame()
<Frame>
<Index>                p       q       r       <<U1>
<IndexHierarchy>
i                a     0       2       4
i                b     1       3       5
j                a     40      42      44
j                b     41      43      45
<<U1>            <<U1> <int64> <int64> <int64>
Batch.unique(*, axis=None)[source]

Return a NumPy array of unqiue values. If the axis argument is provied, uniqueness is determined by columns or row.

>>> bt = sf.Batch((('i', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w'))))
>>> bt.unique().to_frame()
<Frame>
<Index> 0      1      <int64>
<Index>
i       False  True
j       False  True
<<U1>   <bool> <bool>
Batch.unset_index(*, names=(), consolidate_blocks=False, columns_constructors=None)[source]
>>> bt = sf.Batch((('i', sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')), ('j', sf.Frame.from_fields(((23, 83, 19, 87), (True, True, False, False), ('2022-01-01', '2023-04-01', '2022-12-31', '2024-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x'))))
>>> bt.rename(index=('d', 'e')).unset_index().to_frame()
<Frame>
<Index>                  d       e     a       b      c               <<U1>
<IndexHierarchy>
i                0       0       p     10      False  1517-01-01
i                1       0       q     2       True   1517-04-01
i                2       1       p     8       True   1517-12-31
i                3       1       q     3       False  1517-06-30
j                0       0       p     23      True   2022-01-01
j                1       0       q     83      True   2023-04-01
j                2       1       p     19      False  2022-12-31
j                3       1       q     87      False  2024-06-30
<<U1>            <int64> <int64> <<U1> <int64> <bool> <datetime64[D]>
Batch.var(axis=0, skipna=True, ddof=0, out=None)

Return the variance along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> bt = sf.Batch((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'))))
>>> bt.var().to_frame()
<Frame>
<Index> a                  b                  <<U1>
<Index>
i       2.6666666666666665 2.6666666666666665
j       2.6666666666666665 2.6666666666666665
<<U1>   <float64>          <float64>

Batch: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Transpose | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib