cycquery.ops.AddColumnΒΆ
- class AddColumn(add_to, col, negative=False, new_col_labels=None)[source]ΒΆ
Bases:
QueryOp
Add a column to some columns.
- Parameters:
add_to (
Union
[str
,List
[str
]]) β Column names specifying to which columns is being added.col (
str
) β Column name of column to add to the add_to columns.negative (
Optional
[bool
]) β Subtract the column rather than adding.new_col_labels (
Union
[str
,List
[str
],None
]) β If specified, create new columns with these labels. Otherwise, apply the function to the existing columns.
Examples
>>> AddColumn("col1", "col2")(table) >>> AddColumn(["col1", "col2"], "col3")(table) >>> AddColumn("col1", "col2", negative=True)(table) >>> AddColumn("col1", "col2", "col1_plus_col2")(table) >>> AddColumn(["col1", "col2"], "col3", ["col1_plus_col3", "col2_plus_col3"])(table)
Warning
Pay attention to column types. Some combinations will work, whereas others will not.
Methods