cudf.DataFrame.assign#
- DataFrame.assign(**kwargs: Callable[[Self], Any] | Any)[source]#
Assign columns to DataFrame from keyword arguments.
- Parameters:
- **kwargs: dict mapping string column names to values
The value for each key can either be a literal column (or something that can be converted to a column), or a callable of one argument that will be given the dataframe as an argument and should return the new column (without modifying the input argument). Columns are added in-order, so callables can refer to column names constructed in the assignment.
Examples
>>> import cudf >>> df = cudf.DataFrame() >>> df = df.assign(a=[0, 1, 2], b=[3, 4, 5]) >>> df a b 0 0 3 1 1 4 2 2 5