cycquery.ops.ConditionBeforeDateΒΆ

class ConditionBeforeDate(timestamp_col, timestamp, not_=False, binarize_col=None)[source]ΒΆ

Bases: QueryOp

Filter rows based on a timestamp being before some date.

Parameters:
  • timestamp_col (str) – Timestamp column name.

  • timestamp (Union[str, datetime]) – A datetime object or str in YYYY-MM-DD format.

  • not – Take negation of condition.

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

Examples

>>> ConditionBeforeDate("col1", "2020-01-01")(table)
>>> ConditionBeforeDate("col1", datetime.datetime(2020, 1, 1))(table)
>>> ConditionBeforeDate("col1", "2020-01-01", binarize_col="col1_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