overlaps

In [ ]:
overlaps(start0, end0, start1, end1)

Evaluates two time periods and returns true when they overlap, false otherwise.

Parameters

Name Type Optional Description
start0
object
❌
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the beginning of a time period.
end0
object
❌
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the end of a time period.
start1
object
❌
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the beginning of a time period.
end1
object
❌
DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the end of a time period.

Returns

str_sql : SQL expression.

Example

In [1]:
from verticapy import *
df = tablesample({"start0": ['11-03-1993'], 
                  "end0": ['12-03-1993'], 
                  "start1": ['11-30-1993'],
                  "end1": ['11-30-1994']}).to_vdf()
df["start0"].astype("timestamp")
df["start1"].astype("timestamp")
df["end0"].astype("timestamp")
df["end1"].astype("timestamp")
display(df)
📅
start0
Timestamp
📅
end0
Timestamp
📅
start1
Timestamp
📅
end1
Timestamp
11993-11-03 00:00:001993-12-03 00:00:001993-11-30 00:00:001994-11-30 00:00:00
Rows: 1-1 | Columns: 4
In [2]:
# Importing the stats module
import verticapy.stats as st

# Applying the overlaps function
df["overlaps"] = st.overlaps(df["start0"], df["end0"], df["start1"], df["end1"])
display(df)
📅
start0
Timestamp
📅
end0
Timestamp
📅
start1
Timestamp
📅
end1
Timestamp
010
overlaps
Boolean
11993-11-03 00:00:001993-12-03 00:00:001993-11-30 00:00:001994-11-30 00:00:00
✅
Rows: 1-1 | Columns: 5