RelativeTimeRangeFilter
Bases: Filter
This class filters events in an EventTable based on a specified time range relative to an anchor date. The anchor date can either be provided by an anchor phenotype or by an 'INDEX_DATE' column in the EventTable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_days
|
Optional[Value]
|
Minimum number of days from the anchor date to filter events. |
GreaterThanOrEqualTo(0)
|
max_days
|
Optional[Value]
|
Maximum number of days from the anchor date to filter events. |
None
|
anchor_phenotype
|
Optional[Phenotype]
|
A phenotype providing the anchor date for filtering. |
None
|
when
|
Optional[str]
|
when can be "before" or "after"; if "before", days prior to anchor event_date are positive, and days after are negative; using after, days before the anchor event_date are negative and days after the anchor event_date are positive. |
'before'
|
Methods:
Name | Description |
---|---|
filter |
Filters the given EventTable based on the specified time range relative to the anchor date. |
Examples:
# filter events to one year before index date, excluding index date
from phenex.filters.value import LessThan, GreaterThan
one_year_preindex = RelativeTimeRangeFilter(
max_days = LessThan(365),
min_days = GreaterThan(0),
when = 'before'
)
# filter events to one year after index date, including index date
anytime_after_index = RelativeTimeRangeFilter(
min_days = GreaterThan(0),
when = 'after'
)
Source code in phenex/filters/relative_time_range_filter.py
filter(table)
Filters the given table according to the rules of the Filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table
|
PhenexTable
|
The table to be filtered. |
required |
Returns:
Name | Type | Description |
---|---|---|
PhenexTable |
PhenexTable
|
The filtered table. The returned table has the exact same schema as the input table but has rows removed. |