Detail: Yarn: Exporter#
- Yarn.to_manifest(fp, /, *, label_encoder=None)[source]#
Write each contained
Frameas an NPY directory within the directory given byfp. EachFrameis stored as a subdirectory named by its label. Frames from each underlyingBusare extracted, with zip NPY and zip NPZ stores extracting directly without fullFramematerialization.- 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.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=False) >>> y <Yarn> <Index> x Frame y Frame v Frame w Frame <<U1> <object> >>> y.to_manifest('/tmp/y_manifest') >>> sorted(e.name for e in os.scandir('/tmp/y_manifest')) ['v', 'w', 'x', 'y']
- Yarn.to_series()[source]#
Return a
Serieswith theFramecontained in all containedBus.>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=False) >>> y <Yarn> <Index> x Frame y Frame v Frame w Frame <<U1> <object> >>> y.to_series() <Series> <Index> x Frame y Frame v Frame w Frame <<U1> <object>
- Yarn.to_sqlite(fp, /, *, config=None)#
Write the complete
Busas an SQLite database file.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=False) >>> y <Yarn> <Index> x Frame y Frame v Frame w Frame <<U1> <object> >>> y.to_sqlite('/tmp/y.sqlite')
- Yarn.to_visidata()#
Open an interactive VisiData session.
- Yarn.to_xlsx(fp, /, *, config=None)#
Write the complete
Busas a XLSX workbook.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=False) >>> y <Yarn> <Index> x Frame y Frame v Frame w Frame <<U1> <object> >>> y.to_xlsx('/tmp/y.xlsx')
- Yarn.to_zip_csv(fp, /, *, config=None, compression=8)#
Write the complete
Busas a zipped archive of CSV files.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=True) >>> y <Yarn> <IndexHierarchy> i x Frame i y Frame j v Frame j w Frame <<U1> <<U1> <object> >>> y.to_zip_csv('/tmp/y.zip', config=sf.StoreConfig(label_encoder=str))
- Yarn.to_zip_npy(fp, /, *, config=None, compression=8)#
Write the complete
Busas a zipped archive of NPY files.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=True) >>> y <Yarn> <IndexHierarchy> i x Frame i y Frame j v Frame j w Frame <<U1> <<U1> <object> >>> y.to_zip_npy('/tmp/y.zip', config=sf.StoreConfig(label_encoder=str))
- Yarn.to_zip_npz(fp, /, *, config=None, compression=8)#
Write the complete
Busas a zipped archive of NPZ files.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=True) >>> y <Yarn> <IndexHierarchy> i x Frame i y Frame j v Frame j w Frame <<U1> <<U1> <object> >>> y.to_zip_npz('/tmp/y.zip', config=sf.StoreConfig(label_encoder=str))
- Yarn.to_zip_parquet(fp, /, *, config=None, compression=8)#
Write the complete
Busas a zipped archive of parquet files.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=True) >>> y <Yarn> <IndexHierarchy> i x Frame i y Frame j v Frame j w Frame <<U1> <<U1> <object> >>> y.to_zip_parquet('/tmp/y.zip', config=sf.StoreConfig(label_encoder=str))
- Yarn.to_zip_pickle(fp, /, *, config=None, compression=8)#
Write the complete
Busas a zipped archive of pickles.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=True) >>> y <Yarn> <IndexHierarchy> i x Frame i y Frame j v Frame j w Frame <<U1> <<U1> <object> >>> y.to_zip_pickle('/tmp/y.zip', config=sf.StoreConfig(label_encoder=str))
- Yarn.to_zip_tsv(fp, /, *, config=None, compression=8)#
Write the complete
Busas a zipped archive of TSV files.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigcompression – Provide a zip compression setting using values from the Python
zipfilemodule;zipfile.ZIP_DEFLATEDis standard zlib compression;zipfile.ZIP_STOREDdisables compression and may give better performance at the cost of larger file sizes.
>>> 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') >>> 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') >>> y = sf.Yarn.from_buses((b1, b2), retain_labels=True) >>> y <Yarn> <IndexHierarchy> i x Frame i y Frame j v Frame j w Frame <<U1> <<U1> <object> >>> y.to_zip_tsv('/tmp/y.zip', config=sf.StoreConfig(label_encoder=str))
Yarn: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Iterator | Accessor Hashlib | Accessor Type Clinic | Accessor Mapping