cycquery.ops.AddColumn¶
- class AddColumn(add_to, col, negative=False, new_col_labels=None)[source]¶
Bases:
QueryOpAdd 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.
Initialize the operation.
Methods