cycquery.ops.AddNumericΒΆ

class AddNumeric(add_to, add, new_col_labels=None)[source]ΒΆ

Bases: QueryOp

Add a numeric value to some columns.

Parameters:
  • add_to (Union[str, List[str]]) – Column names specifying to which columns is being added.

  • add (Union[int, float, List[int], List[float]]) – Adds this value to the add_to columns.

  • 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

>>> AddNumeric("col1", 1)(table)
>>> AddNumeric(["col1", "col2"], 1)(table)
>>> AddNumeric("col1", 1, "col1_plus_1")(table)
>>> AddNumeric(["col1", "col2"], 1, ["col1_plus_1", "col2_plus_1"])(table)
>>> AddNumeric(["col1", "col2"], [1, 2.2])(table)

Methods

__call__(table)[source]ΒΆ

Process the table.

Parameters:

table (Union[Select, Subquery, Table, DBTable]) – Table on which to perform the operation.

Returns:

Processed table.

Return type:

sqlalchemy.sql.selectable.Subquery