Detail: FrameGO: Assignment
- FrameGO.assign[key](value, *, fill_value)
- assign
- FrameAssign.__call__(value, *, fill_value=nan)[source]
Assign the
value
in the position specified by the selector. The name attribute is propagated to the returned container.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign['a'](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p -1 8 1 q -1 -3 0 r -1 8 9 s -1 0 12 <<U1> <int64> <int64> <int64> >>> f.assign[['a', 'c']](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p -1 8 -1 q -1 -3 -1 r -1 8 -1 s -1 0 -1 <<U1> <int64> <int64> <int64>
- FrameGO.assign[key].apply(func, *, fill_value)
- FrameGO.assign
- FrameAssign.apply(func, *, fill_value=nan)[source]
Provide a function to apply to the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign['a'].apply(lambda s: s / 100) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 0.1 8 1 q -0.02 -3 0 r 0.0 8 9 s 0.0 0 12 <<U1> <float64> <int64> <int64>
- FrameGO.assign[key].apply_element(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element(func, *, dtype=None, fill_value=nan)[source]
Provide a function to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign['a'].apply_element(lambda e: e / 100 if e < 8 else e) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10.0 8 1 q -0.02 -3 0 r 0.0 8 9 s 0.0 0 12 <<U1> <float64> <int64> <int64>
- FrameGO.assign[key].apply_element_items(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element_items(func, *, dtype=None, fill_value=nan)[source]
Provide a function, taking pairs of label, element, to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function, taking pairs of label, element, to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign['a'].apply_element_items(lambda l, e: e / 100 if l == ('q', 'a') else e) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64>
- FrameGO.assign.iloc[key](value, *, fill_value)
- FrameGO.assign
- FrameAssign.__call__(value, *, fill_value=nan)[source]
Assign the
value
in the position specified by the selector. The name attribute is propagated to the returned container.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.iloc[2]((-1, -2, -3)) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r (-1, -2, -3) (-1, -2, -3) (-1, -2, -3) s 0 0 12 <<U1> <object> <object> <object> >>> f.assign.iloc[2:](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r -1 -1 -1 s -1 -1 -1 <<U1> <int64> <int64> <int64> >>> f.assign.iloc[[0, 3]](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p -1 -1 -1 q -2 -3 0 r 0 8 9 s -1 -1 -1 <<U1> <int64> <int64> <int64>
- FrameGO.assign.iloc[key].apply(func, *, fill_value)
- FrameGO.assign
- FrameAssign.apply(func, *, fill_value=nan)[source]
Provide a function to apply to the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.iloc[2:].apply(lambda s: s / 100) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10.0 8.0 1.0 q -2.0 -3.0 0.0 r 0.0 0.08 0.09 s 0.0 0.0 0.12 <<U1> <float64> <float64> <float64>
- FrameGO.assign.iloc[key].apply_element(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element(func, *, dtype=None, fill_value=nan)[source]
Provide a function to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.iloc[1:].apply_element(lambda e: e / 100 if e < 8 else e) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10.0 8.0 1.0 q -0.02 -0.03 0.0 r 0.0 8.0 9.0 s 0.0 0.0 12.0 <<U1> <float64> <float64> <float64>
- FrameGO.assign.iloc[key].apply_element_items(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element_items(func, *, dtype=None, fill_value=nan)[source]
Provide a function, taking pairs of label, element, to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function, taking pairs of label, element, to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.iloc[1:].apply_element_items(lambda l, e: e / 100 if l == ('q', 'a') else e) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10.0 8 1 q -0.02 -3 0 r 0.0 8 9 s 0.0 0 12 <<U1> <float64> <int64> <int64>
- FrameGO.assign.loc[key](value, *, fill_value)
- FrameGO.assign
- FrameAssign.__call__(value, *, fill_value=nan)[source]
Assign the
value
in the position specified by the selector. The name attribute is propagated to the returned container.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.loc['r'](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r -1 -1 -1 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.loc['r':](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r -1 -1 -1 s -1 -1 -1 <<U1> <int64> <int64> <int64> >>> f.assign.loc[['p', 's']](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p -1 -1 -1 q -2 -3 0 r 0 8 9 s -1 -1 -1 <<U1> <int64> <int64> <int64>
- FrameGO.assign.loc[key].apply(func, *, fill_value)
- FrameGO.assign
- FrameAssign.apply(func, *, fill_value=nan)[source]
Provide a function to apply to the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.loc['r':].apply(lambda s: s / 100) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10.0 8.0 1.0 q -2.0 -3.0 0.0 r 0.0 0.08 0.09 s 0.0 0.0 0.12 <<U1> <float64> <float64> <float64>
- FrameGO.assign.loc[key].apply_element(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element(func, *, dtype=None, fill_value=nan)[source]
Provide a function to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.loc['r':].apply_element(lambda e: e / 100 if e < 10 else e) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10.0 8.0 1.0 q -2.0 -3.0 0.0 r 0.0 0.08 0.09 s 0.0 0.0 12.0 <<U1> <float64> <float64> <float64>
- FrameGO.assign.loc[key].apply_element_items(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element_items(func, *, dtype=None, fill_value=nan)[source]
Provide a function, taking pairs of label, element, to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function, taking pairs of label, element, to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.loc['r':].apply_element_items(lambda l, e: e / 100 if l[1] == 'c' else e) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1.0 q -2 -3 0.0 r 0 8 0.09 s 0 0 0.12 <<U1> <int64> <int64> <float64>
- FrameGO.assign.bloc[key](value, *, fill_value)
- FrameGO.assign
- FrameAssign.__call__(value, *, fill_value=nan)[source]
Assign the
value
in the position specified by the selector. The name attribute is propagated to the returned container.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.bloc[f > 5](-1) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p -1 -1 1 q -2 -3 0 r 0 -1 -1 s 0 0 -1 <<U1> <int64> <int64> <int64>
- FrameGO.assign.bloc[key].apply(func, *, fill_value)
- FrameGO.assign
- FrameAssign.apply(func, *, fill_value=nan)[source]
Provide a function to apply to the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.bloc[f > 5].apply(lambda s: s * .01) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 0.1 0.08 1.0 q -2.0 -3.0 0.0 r 0.0 0.08 0.09 s 0.0 0.0 0.12 <<U1> <float64> <float64> <float64>
- FrameGO.assign.bloc[key].apply_element(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element(func, *, dtype=None, fill_value=nan)[source]
Provide a function to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.bloc[f > 5].apply_element(lambda e: e * .01 if e == 8 else e) <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10.0 0.08 1.0 q -2.0 -3.0 0.0 r 0.0 0.08 9.0 s 0.0 0.0 12.0 <<U1> <float64> <float64> <float64>
- FrameGO.assign.bloc[key].apply_element_items(func, *, dtype, fill_value)
- FrameGO.assign
- FrameAssign.apply_element_items(func, *, dtype=None, fill_value=nan)[source]
Provide a function, taking pairs of label, element, to apply to each element in the assignment target, and use that as the assignment value.
- Parameters:
func – A function, taking pairs of label, element, to apply to the assignment target.
* –
fill_value – If the function does not produce a container with a matching index, the element will be used to fill newly created elements.
>>> f = sf.FrameGO.from_fields(((10, -2, 0, 0), (8, -3, 8, 0), (1, 0, 9, 12)), index=('p', 'q', 'r', 's'), columns=('a', 'b', 'c'), name='x') >>> f <FrameGO: x> <IndexGO> a b c <<U1> <Index> p 10 8 1 q -2 -3 0 r 0 8 9 s 0 0 12 <<U1> <int64> <int64> <int64> >>> f.assign.bloc[f > 5].apply_element_items(lambda e: e * .01 if l[1] == 'c' else e) TypeError('<lambda>() takes 1 positional argument but 2 were given')
FrameGO: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Assignment | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Transpose | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic | Accessor Reduce