datatable.Frame.__setitem__()¶
This methods updates values within the frame, or adds new columns to the frame.
All parameters have the same meaning as in the getter
DT[i, j, ...], with the only
restriction that j must select to columns by reference (i.e. there
could not be any computed columns there). On the other hand, j may
contain columns that do not exist in the frame yet: these columns will be
created.
Parameters¶
...Row selector.
...Column selector. Computed columns are forbidden, but not-existing (new) columns are allowed.
byGroupby condition.
joinJoin criterion.
FExpr | List[FExpr] | Frame | type | None | bool | int | float | strThe replacement for the selection on the left-hand-side.
None|bool|int|float|strA simple python scalar can be assigned to any-shape selection on the LHS. If
iselects all rows (i.e. the assignment is of the formDT[:, j] = R), then each column injwill be replaced with a constant column containing the valueR.If, on the other hand,
iselects only some rows, then the type ofRmust be consistent with the type of column(s) selected inj. In this case only cells in subset[i, j]will be updated with the value ofR; the columns may be promoted within their ltype if the value ofRis large in magnitude.type|stype|ltypeAssigning a type to one or more columns will change the types of those columns. The row selector
imust be “slice-all”:.Frame|FExpr|List[FExpr]When a frame or an expression is assigned, then the shape of the RHS must match the shape of the LHS. Similarly to the assignment of scalars, types must be compatible when assigning to a subset of rows.
See Also¶
dt.update()– An alternative way to update values in the frame withinDT[i, j]getter..replace()– Search and replace for certain values within the entire frame.
A simplified form of the setter, suitable for a single-column replacement.
In this case j may only be an integer or a string.