Detail: Quilt: Constructor

Overview: Quilt: Constructor

Quilt.__init__(bus, *, axis=0, retain_labels, axis_hierarchy=None, axis_opposite=None, deepcopy_from_bus=False)[source]
Parameters
  • busBus of Frame to be used for virtual concatenation.

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1
<Quilt: j>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q1.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
>>> q2 = sf.Quilt(b, retain_labels=True, axis=1)
>>> q2
<Quilt: j>
<Index: Frames>  x v
<Index: Aligned>
p                . .
q                . .
r                . .
<<U1>
>>> q2.to_frame()
<Frame>
<IndexHierarchy> x       x       v       v       <<U1>
                 a       b       a       b       <<U1>
<Index>
p                0       1       40      41
q                2       3       42      43
r                4       5       44      45
<<U1>            <int64> <int64> <int64> <int64>
classmethod Quilt.from_frame(frame, *, chunksize, retain_labels, axis=0, name=None, label_extractor=None, config=None, deepcopy_from_bus=False)[source]

Given a Frame, create a Quilt by partitioning it along the specified axis in units of chunksize, where axis 0 partitions vertically (retaining aligned columns) and 1 partions horizontally (retaining aligned index).

Parameters

label_extractor – Function that, given the partitioned index component along the specified axis, returns a string label for that chunk.

>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')
>>> q = sf.Quilt.from_frame(f, retain_labels=True, chunksize=2)
>>> q
<Quilt: x>
<Index: Aligned> a b c <<U1>
<Index: Frames>
0                . . .
2                . . .
<int64>
>>> q.to_frame()
<Frame>
<Index>                  a       b      c               <<U1>
<IndexHierarchy>
0                0       10      False  1517-01-01
0                1       2       True   1517-04-01
2                2       8       True   1517-12-31
2                3       3       False  1517-06-30
<int64>          <int64> <int64> <bool> <datetime64[D]>
classmethod Quilt.from_frames(frames, *, axis=0, name=None, retain_labels, deepcopy_from_bus=False)[source]

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

>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f2 = sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')
>>> q = sf.Quilt.from_frames((f1, f2), retain_labels=True)
>>> q
<Quilt>
<Index: Aligned> a b <<U1>
<Index: Frames>
x                . .
v                . .
<<U1>
>>> q.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_hdf5(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_hdf5('/tmp/q.hdf5')
>>> q2 = sf.Quilt.from_hdf5('/tmp/q.hdf5', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
v                p     40      41
v                q     42      43
v                r     44      45
x                p     0       1
x                q     2       3
x                r     4       5
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_items(items, *, axis=0, name=None, retain_labels, deepcopy_from_bus=False)[source]

Given an iterable of pairs of label, Frame, create a Quilt.

>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f2 = sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')
>>> q = sf.Quilt.from_items((('A', f1), ('B', f2)), retain_labels=True)
>>> q
<Quilt>
<Index: Aligned> a b <<U1>
<Index: Frames>
A                . .
B                . .
<<U1>
>>> q.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
A                p     0       1
A                q     2       3
A                r     4       5
B                p     40      41
B                q     42      43
B                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_sqlite(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_sqlite('/tmp/q.db')
>>> q2 = sf.Quilt.from_sqlite('/tmp/q.db', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_xlsx(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_xlsx('/tmp/q.xlsx')
>>> q2 = sf.Quilt.from_xlsx('/tmp/q.xlsx', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_zip_csv(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_zip_csv('/tmp/q.zip')
>>> q2 = sf.Quilt.from_zip_csv('/tmp/q.zip', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_zip_npy(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_zip_npy('/tmp/q.zip')
>>> q2 = sf.Quilt.from_zip_npy('/tmp/q.zip', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_zip_npz(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_zip_npz('/tmp/q.zip')
>>> q2 = sf.Quilt.from_zip_npz('/tmp/q.zip', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_zip_parquet(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_zip_parquet('/tmp/q.zip')
>>> q2 = sf.Quilt.from_zip_parquet('/tmp/q.zip', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                   a       b       <<U1>
<IndexHierarchy>
x                p        0       1
x                q        2       3
x                r        4       5
v                p        40      41
v                q        42      43
v                r        44      45
<<U1>            <object> <int64> <int64>
classmethod Quilt.from_zip_pickle(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_zip_pickle('/tmp/q.zip')
>>> q2 = sf.Quilt.from_zip_pickle('/tmp/q.zip', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>
classmethod Quilt.from_zip_tsv(fp, *, config=None, axis=0, retain_labels, deepcopy_from_bus=False, max_persist=None)[source]

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

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

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

  • axis – Integer specifying axis of virtual concatenation, where 0 is vertically (stacking rows) and 1 is horizontally (extending columns).

  • retain_labels – Boolean to determine if, along the axis of virtual concatentation, if component Frame labels should be used to form the outer depth of an IndexHierarchy. This is required to be True if component Frame labels are not globally unique along the axis of concatenation.

  • deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained Bus during extraction. Set to True to avoid holding references from the Bus.

  • 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(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v')), name='j')
>>> q1 = sf.Quilt(b, retain_labels=True)
>>> q1.to_zip_tsv('/tmp/q.zip')
>>> q2 = sf.Quilt.from_zip_tsv('/tmp/q.zip', retain_labels=True, config=sf.StoreConfig(index_depth=1))
>>> q2.to_frame()
<Frame>
<Index>                a       b       <<U1>
<IndexHierarchy>
x                p     0       1
x                q     2       3
x                r     4       5
v                p     40      41
v                q     42      43
v                r     44      45
<<U1>            <<U1> <int64> <int64>

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