cycquery.ops.ExtractTimestampComponentยถ

class ExtractTimestampComponent(timestamp_col, extract_str, label)[source]ยถ

Bases: QueryOp

Extract a component such as year or month from a timestamp column.

Parameters:
  • timestamp_col (str) โ€“ Timestamp column from which to extract the time component.

  • extract_str (str) โ€“ Information to extract, e.g., โ€œyearโ€, โ€œmonthโ€

  • label (str) โ€“ Column label for the extracted column.

Examples

>>> ExtractTimestampComponent("col1", "year", "year")(table)
>>> ExtractTimestampComponent("col1", "month", "month")(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