Detail: Bus: Exporter#

Overview: Bus: Exporter

Bus.to_manifest(fp, /, *, label_encoder=None)[source]#

Write each contained Frame as an NPY directory within the directory given by fp. Each Frame is stored as a subdirectory named by its label. When the Bus is backed by a zip NPY or zip NPZ store, arrays are extracted directly without full Frame materialization.

Parameters:
  • fp – directory path in which to write the manifest.

  • label_encoder – callable to convert non-string labels to strings for use as directory names. Required when labels are not strings.

>>> 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_manifest('/tmp/b_manifest')
>>> sorted(e.name for e in os.scandir('/tmp/b_manifest'))
['x', 'y']
Bus.to_series()[source]#

Return a Series with the Frame contained in this Bus. If the Bus is associated with a Store, all Frame will be loaded into memory and the returned Bus will no longer be associated with the Store.

>>> 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_series()
<Series: i>
<Index>
x           Frame
y           Frame
<<U1>       <object>
Bus.to_sqlite(fp, /, *, config=None)#

Write the complete Bus as an SQLite database file.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')
Bus.to_visidata()#

Open an interactive VisiData session.

Bus.to_xlsx(fp, /, *, config=None)#

Write the complete Bus as a XLSX workbook.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')
Bus.to_zip_csv(fp, /, *, config=None, compression=8)#

Write the complete Bus as a zipped archive of CSV files.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')
Bus.to_zip_npy(fp, /, *, config=None, compression=8)#

Write the complete Bus as a zipped archive of NPY files.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')
Bus.to_zip_npz(fp, /, *, config=None, compression=8)#

Write the complete Bus as a zipped archive of NPZ files.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')
Bus.to_zip_parquet(fp, /, *, config=None, compression=8)#

Write the complete Bus as a zipped archive of parquet files.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')
Bus.to_zip_pickle(fp, /, *, config=None, compression=8)#

Write the complete Bus as a zipped archive of pickles.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')
Bus.to_zip_tsv(fp, /, *, config=None, compression=8)#

Write the complete Bus as a zipped archive of TSV files.

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

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

  • compression – Provide a zip compression setting using values from the Python zipfile module; zipfile.ZIP_DEFLATED is standard zlib compression; zipfile.ZIP_STORED disables compression and may give better performance at the cost of larger file sizes.

>>> 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')

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