verticapy.sql.functions.overlaps#
- verticapy.sql.functions.overlaps(start0: str | list[str] | StringSQL | list[StringSQL], end0: str | list[str] | StringSQL | list[StringSQL], start1: str | list[str] | StringSQL | list[StringSQL], end1: str | list[str] | StringSQL | list[StringSQL]) StringSQL #
Evaluates two time periods and returns true when they overlap, false otherwise.
Parameters#
- start0: SQLExpression
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the beginning of a time period.
- end0: SQLExpression
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the end of a time period.
- start1: SQLExpression
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the beginning of a time period.
- end1: SQLExpression
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the end of a time period.
Returns#
- StringSQL
SQL string.
Examples#
First, let’s import the vDataFrame in order to create a dummy dataset.
from verticapy import vDataFrame
Now, let’s import the VerticaPy SQL functions.
import verticapy.sql.functions as vpf
We can now build a dummy dataset.
df = vDataFrame( { "start0": ['11-03-1993'], "end0": ['12-03-1993'], "start1": ['11-30-1993'], "end1": ['11-30-1994'], }, ) df["start0"].astype("timestamp") df["start1"].astype("timestamp") df["end0"].astype("timestamp") df["end1"].astype("timestamp")
Now, let’s go ahead and apply the function.
df["overlaps"] = vpf.overlaps(df["start0"], df["end0"], df["start1"], df["end1"]) display(df)
📅start0Timestamp100%... 📅end1Timestamp100%010overlapsBoolean100%1 1993-11-03 00:00:00 ... 1994-11-30 00:00:00 ✅ Note
It’s crucial to utilize VerticaPy SQL functions in coding, as they can be updated over time with new syntax. While SQL functions typically remain stable, they may vary across platforms or versions. VerticaPy effectively manages these changes, a task not achievable with pure SQL.
See also
vDataFrame.
eval()
: Evaluates the expression.