cycquery.ops.ConditionLikeΒΆ

class ConditionLike(col, pattern, not_=False, binarize_col=None)[source]ΒΆ

Bases: QueryOp

Filter rows by a LIKE condition.

Parameters:
  • col (str) – Column to filter on.

  • pattern (str) – Pattern to filter on.

  • not – Take negation of condition.

  • binarize_col (Optional[str]) – If specified, create a Boolean column of name binarize_col instead of filtering.

Examples

>>> ConditionLike("lab_name", "HbA1c")(table)
>>> ConditionLike("lab_name", "HbA1c", not_=True)(table)
>>> ConditionLike("lab_name", "HbA1c", binarize_col="lab_name_bool")(table)

Methods

__call__(table, return_cond=False)[source]ΒΆ

Process the table.

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

  • return_cond (bool) – Return the condition instead of filtering.

Returns:

Processed table.

Return type:

sqlalchemy.sql.selectable.Subquery