otp.Source.update#
- Source.update(if_set, else_set=None, where=1, inplace=False)[source]#
Update field of the Source
- Parameters
if_set (dict) – Dictionary <field name>: <expression>.
else_set (dict, optional) – Dictionary <field name>: <expression>
where (expression, optional) –
Condition of updating.
If
where
is True the fields fromif_set
will be updated with corresponding expression.If
where
is False, the fields fromelse_set
will be updated with corresponding expression.inplace (bool) – A flag controls whether operation should be applied inplace. If
inplace=True
, then it returns nothing. Otherwise method returns a new modified object.
- Return type
Source
orNone
.
Examples
>>> t = otp.Ticks({'X': [1, 2, 3], ... 'Y': [4, 5, 6], ... 'Z': [1, 0, 1]}) >>> t = t.update(if_set={'X': t['X'] + t['Y']}, ... else_set={'X': t['X'] - t['Y']}, ... where=t['Z'] == 1) >>> t() Time X Y Z 0 2003-12-01 00:00:00.000 5 4 1 1 2003-12-01 00:00:00.001 -3 5 0 2 2003-12-01 00:00:00.002 9 6 1
See also
UPDATE_FIELD and UPDATE_FIELDS OneTick event processors