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.
by
Groupby condition.
join
Join criterion.
FExpr
| List[FExpr]
| Frame
| type
| None
| bool
| int
| float
| str
The replacement for the selection on the left-hand-side.
None
|bool
|int
|float
|str
A simple python scalar can be assigned to any-shape selection on the LHS. If
i
selects all rows (i.e. the assignment is of the formDT[:, j] = R
), then each column inj
will be replaced with a constant column containing the valueR
.If, on the other hand,
i
selects only some rows, then the type ofR
must 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 ofR
is large in magnitude.type
|stype
|ltype
Assigning a type to one or more columns will change the types of those columns. The row selector
i
must 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¶
update()
– An alternative way to update values in the frame withinDT[i, j]
getter.Frame.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.