Detail: Quilt: Constructor#
- Quilt.__init__(bus, /, *, axis=0, retain_labels, axis_hierarchy=None, axis_opposite=None, deepcopy_from_bus=False)[source]#
- Parameters:
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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.
>>> 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, deepcopy_from_bus=False)[source]#
Given a
Frame, create aQuiltby partitioning it along the specifiedaxisin units ofchunksize, whereaxis0 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
Quiltfrom an iterable ofFrame; labels will be drawn fromFrame.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_items(items, /, *, axis=0, name=None, retain_labels, deepcopy_from_bus=False)[source]#
Given an iterable of pairs of label,
Frame, create aQuilt.>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 0 1 q 2 3 r 4 5 <<U1> <int64> <int64> >>> f2 = sf.Frame(np.arange(40, 46).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='v') >>> f2 <Frame: v> <Index> a b <<U1> <Index> p 40 41 q 42 43 r 44 45 <<U1> <int64> <int64> >>> 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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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
Quiltstore, return aQuiltinstance.- Parameters:
fp – A string file path or
Pathinstance.config – A
StoreConfig, or a mapping of label toStoreConfigaxis – 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
Framelabels should be used to form the outer depth of anIndexHierarchy. This is required to beTrueif componentFramelabels are not globally unique along the axis of concatenation.deepcopy_from_bus – Boolean to determine if containers are deep-copied from the contained
Busduring extraction. Set toTrueto avoid holding references from theBus.max_persist – When loading
Framefrom aStore, optionally define the maximum number ofFrameto remain in theBus, regardless of the size of theBus. If more thanmax_persistnumber ofFrameare loaded, least-recently loadedFramewill be replaced byFrameDeferred. Amax_persistof 1, for example, permits reading oneFrameat a time without ever holding in memory more than 1Frame.
>>> 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_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 | Accessor Type Clinic