Detail: Bus: Constructor

Overview: Bus: Constructor

Bus.__init__(frames, *, index, index_constructor=None, name=<object object>, store=None, config=None, max_persist=None, own_index=False, own_data=False)[source]

Default Bus constructor.

{args}

>>> sf.Bus((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), index=('a', 'b'))
<Bus>
<Index>
a       Frame
b       Frame
<<U1>   <object>
classmethod Bus.from_concat(containers, *, index=None, name=<object object>)[source]

Concatenate multiple Bus into a new Bus. All Bus will load all Frame into memory if any are deferred.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b1
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b2 = sf.Bus.from_frames((sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v'), sf.Frame((np.arange(6).reshape(3,2) % 3).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='w')), name='j')
>>> b2
<Bus: j>
<Index>
v        Frame
w        Frame
<<U1>    <object>
>>> sf.Bus.from_concat((b1, b2))
<Bus>
<Index>
x       Frame
y       Frame
v       Frame
w       Frame
<<U1>   <object>
classmethod Bus.from_dict(mapping, *, name=None, index_constructor=None)[source]

Bus construction from a mapping of labels and Frame.

Parameters:

mapping – a dictionary or similar mapping interface.

Returns:

Bus

>>> sf.Bus.from_dict(dict(j=sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), k=sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')))
<Bus>
<Index>
j       Frame
k       Frame
<<U1>   <object>
classmethod Bus.from_frames(frames, *, index_constructor=None, config=None, name=None)[source]

Return a Bus from an iterable of Frame; labels will be drawn from Frame.name.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
classmethod Bus.from_hdf5(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to a HDF5 Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_hdf5('/tmp/b.hdf5')
>>> sf.Bus.from_hdf5('/tmp/b.hdf5')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_items(pairs, *, config=None, name=None, index_constructor=None)[source]

Return a Bus from an iterable of pairs of label, Frame.

Returns:

Bus

>>> sf.Bus.from_items((('i', sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')), ('j', sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y'))))
<Bus>
<Index>
i       Frame
j       Frame
<<U1>   <object>
classmethod Bus.from_series(series, *, store=None, config=None, max_persist=None, own_data=False)[source]

Create a Bus from a Series of Frame.

>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f2 = sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')
>>> s = sf.Series((f1, f2), index=(f1.name, f2.name))
>>> sf.Bus.from_series(s)
<Bus>
<Index>
x       Frame
y       Frame
<<U1>   <object>
classmethod Bus.from_sqlite(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to an SQLite Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_sqlite('/tmp/b.sqlite')
>>> sf.Bus.from_sqlite('/tmp/b.sqlite')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_xlsx(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to an XLSX Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_xlsx('/tmp/b.xlsx')
>>> sf.Bus.from_xlsx('/tmp/b.xlsx')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_zip_csv(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to zipped CSV Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_zip_csv('/tmp/b.zip')
>>> sf.Bus.from_zip_csv('/tmp/b.zip')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_zip_npy(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to zipped NPY Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_zip_npy('/tmp/b.zip')
>>> sf.Bus.from_zip_npy('/tmp/b.zip')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_zip_npz(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to zipped NPZ Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_zip_npz('/tmp/b.zip')
>>> sf.Bus.from_zip_npz('/tmp/b.zip')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_zip_parquet(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to zipped parquet Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_zip_parquet('/tmp/b.zip')
>>> sf.Bus.from_zip_parquet('/tmp/b.zip')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_zip_pickle(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to zipped pickle Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_zip_pickle('/tmp/b.zip')
>>> sf.Bus.from_zip_pickle('/tmp/b.zip')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>
classmethod Bus.from_zip_tsv(fp, *, config=None, max_persist=None, index_constructor=None)[source]

Given a file path to zipped TSV Bus store, return a Bus instance.

Parameters:
  • fp – A string file path or Path instance.

  • config – A StoreConfig, or a mapping of label ot StoreConfig

  • max_persist – When loading Frame from a Store, optionally define the maximum number of Frame to remain in the Bus, regardless of the size of the Bus. If more than max_persist number of Frame are loaded, least-recently loaded Frame will be replaced by FrameDeferred. A max_persist of 1, for example, permits reading one Frame at a time without ever holding in memory more than 1 Frame.

>>> 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(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.to_zip_tsv('/tmp/b.zip')
>>> sf.Bus.from_zip_tsv('/tmp/b.zip')
<Bus>
<Index>
x       <FrameDeferred>
y       <FrameDeferred>
<<U1>   <object>

Bus: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Iterator | Accessor Hashlib | Accessor Type Clinic