cycquery.ops.TrimΒΆ

class Trim(cols, new_col_labels=None)[source]ΒΆ

Bases: QueryOp

Trim the whitespace from some string columns.

Parameters:
  • cols (Union[str, List[str]]) – Columns to trim.

  • 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

>>> Trim("col1")(table)
>>> Trim(["col1", "col2"])(table)
>>> Trim("col1", "col1_trimmed")(table)
>>> Trim(["col1", "col2"], ["col1_trimmed", "col2_trimmed"])(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