Detail: Yarn: Constructor

Overview: Yarn: Constructor

Yarn.__init__(series, *, index=None, index_constructor=None, deepcopy_from_bus=False, indexer=None, hierarchy=None, name=None, own_index=False)[source]
Parameters:
  • series – An iterable (or Series) of Bus. The length of this container may not be the same as index, if provided.

  • index – Optionally provide an index for the Frame contained in all Bus.

  • index_constructor

  • deepcopy_from_bus

  • hierarchy – Optionally provide a depth-two IndexHierarchy constructed from Bus integer positions on the outer level, and contained Frame labels on the inner level.

  • indexer – For each Frame referenced by the index, provide the location within the internal IndexHierarchy.

  • name

  • own_index

>>> 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.Yarn((b1, b2), index=('2020-01', '2020-02', '2020-03', '2020-04'), index_constructor=sf.IndexYearMonth)
<Yarn>
<IndexYearMonth>
2020-01          Frame
2020-02          Frame
2020-03          Frame
2020-04          Frame
<datetime64[M]>  <object>
classmethod Yarn.from_buses(buses, *, name=None, retain_labels, deepcopy_from_bus=False)[source]

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

>>> 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.Yarn.from_buses((b1, b2), retain_labels=True)
<Yarn>
<IndexHierarchy>
i                x     Frame
i                y     Frame
j                v     Frame
j                w     Frame
<<U1>            <<U1> <object>
>>> sf.Yarn.from_buses((b1, b2), retain_labels=False)
<Yarn>
<Index>
x       Frame
y       Frame
v       Frame
w       Frame
<<U1>   <object>
classmethod Yarn.from_concat(containers, *, index=None, name=<object object>, deepcopy_from_bus=False)[source]

Concatenate multiple Yarn into a new Yarn. Loaded status of Frame within each Bus will not be altered.

Parameters:
  • containers

  • index – Optionally provide new labels for the result of the concatenation.

  • name

  • deepcopy_from_bus

>>> 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>
>>> b3 = 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'), 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='k')
>>> b3
<Bus: k>
<Index>
x        Frame
y        Frame
v        Frame
w        Frame
<<U1>    <object>
>>> y1 = sf.Yarn.from_buses((b1, b2), retain_labels=True)
>>> y1
<Yarn>
<IndexHierarchy>
i                x     Frame
i                y     Frame
j                v     Frame
j                w     Frame
<<U1>            <<U1> <object>
>>> y2 = sf.Yarn.from_buses((b3,), retain_labels=True)
>>> y2
<Yarn>
<IndexHierarchy>
k                x     Frame
k                y     Frame
k                v     Frame
k                w     Frame
<<U1>            <<U1> <object>
>>> sf.Yarn.from_concat((y1, y2))
<Yarn>
<IndexHierarchy>
i                x     Frame
i                y     Frame
j                v     Frame
j                w     Frame
k                x     Frame
k                y     Frame
k                v     Frame
k                w     Frame
<<U1>            <<U1> <object>

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