Condition functions
Functions
| Name | Description |
|---|---|
condition_and | Combines multiple conditions using logical AND. |
condition_or | Combines multiple conditions using logical OR. |
is_all_numbers_only | Checks if the given column or string contains only numeric characters. |
is_array_monotonic | Check if an array column is monotonic according to a comparator and a NULL policy. |
is_array_non_decreasing | Check if an array column is non-decreasing. |
is_array_non_increasing | Check if an array column is non-increasing. |
is_array_strictly_decreasing | Check if an array column is strictly decreasing. |
is_array_strictly_increasing | Check if an array column is strictly increasing. |
is_n_character_only | Checks if the given column or string contains exactly n alphabetic characters. |
is_n_numbers_only | Checks if the given column or string contains exactly n numeric characters. |
is_printable_only | Checks if the given column or string contains only printable characters. |
is_two_character_only | Checks if the given column or string contains exactly two alphabetic characters (either lowercase or uppercase). |
startswiths | Creates a PySpark Column expression to check if the given column starts with any string in the list. |
condition_andfunction#
def condition_and(*conditions: ColumnOrName) -> ColumnCombines multiple conditions using logical AND.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
*conditions | ColumnOrName | () | Multiple PySpark Column objects or SQL expression strings representing conditions. |
Returns
ColumnColumn- A single PySpark Column object representing the combined condition.
condition_orfunction#
def condition_or(*conditions: ColumnOrName) -> ColumnCombines multiple conditions using logical OR.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
*conditions | ColumnOrName | () | Multiple PySpark Column objects or SQL expression strings representing conditions. |
Returns
ColumnColumn- A single PySpark Column object representing the combined condition.
is_all_numbers_onlyfunction#
def is_all_numbers_only(column_or_name) -> ColumnChecks if the given column or string contains only numeric characters.
Parameters
| Name | Type | Description |
|---|---|---|
column_or_name | ColumnOrName | The column or string to be checked. |
Returns
ColumnColumn- A column of boolean values indicating whether each entry contains only numeric characters.
is_array_monotonicfunction#
def is_array_monotonic(col: ColumnOrName, cmp_fn: Callable, null_policy: str = 'forbid') -> ColumnCheck if an array column is monotonic according to a comparator and a NULL policy.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
col | ColumnOrName | required | Array column to check. |
cmp_fn | callable | required | Binary function (x, y) -> Column[bool]-like. Typical choices: operator.lt # strictly increasing operator.le # non-decreasing operator.gt # strictly decreasing operator.ge # non-increasing |
null_policy | str | 'forbid' | How to treat NULL elements inside the array:
|
Returns
ColumnColumn- Boolean column: True if the array is monotonic under the chosen comparator
Column- and NULL policy. Empty / single-element arrays return True.
is_array_non_decreasingfunction#
def is_array_non_decreasing(col: ColumnOrName, null_policy: str = 'forbid') -> ColumnCheck if an array column is non-decreasing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
col | ColumnOrName | required | Array column to check |
null_policy | str | 'forbid' | How to treat NULL elements inside the array. |
Returns
ColumnColumn- Boolean column: True if the array is non-decreasing, False otherwise.
is_array_non_increasingfunction#
def is_array_non_increasing(col: ColumnOrName, null_policy: str = 'forbid') -> ColumnCheck if an array column is non-increasing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
col | ColumnOrName | required | Array column to check |
null_policy | str | 'forbid' | How to treat NULL elements inside the array. |
Returns
ColumnColumn- Boolean column: True if the array is non-increasing, False otherwise.
is_array_strictly_decreasingfunction#
def is_array_strictly_decreasing(col: ColumnOrName, null_policy: str = 'forbid') -> ColumnCheck if an array column is strictly decreasing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
col | ColumnOrName | required | Array column to check |
null_policy | str | 'forbid' | How to treat NULL elements inside the array. |
Returns
ColumnColumn- Boolean column: True if the array is strictly decreasing, False otherwise.
is_array_strictly_increasingfunction#
def is_array_strictly_increasing(col: ColumnOrName, null_policy: str = 'forbid') -> ColumnCheck if an array column is strictly increasing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
col | ColumnOrName | required | Array column to check |
null_policy | str | 'forbid' | How to treat NULL elements inside the array. |
Returns
ColumnColumn- Boolean column: True if the array is strictly increasing, False otherwise.
is_n_character_onlyfunction#
def is_n_character_only(column_or_name: ColumnOrName, n: int) -> ColumnChecks if the given column or string contains exactly n alphabetic characters.
Parameters
| Name | Type | Description |
|---|---|---|
column_or_name | Column | The column or string to be checked. |
n | int | The exact number of alphabetic characters to match. |
Returns
ColumnColumn- A column of boolean values indicating whether each entry matches the regular expression.
is_n_numbers_onlyfunction#
def is_n_numbers_only(column_or_name: ColumnOrName, n: int | str) -> ColumnChecks if the given column or string contains exactly n numeric characters.
Parameters
| Name | Type | Description |
|---|---|---|
column_or_name | ColumnOrName | The column or string to be checked. |
n | int | str | The exact number of numeric characters to match. or “+” for any length number. |
Returns
ColumnColumn- A column of boolean values indicating whether each entry matches the regular expression.
is_printable_onlyfunction#
def is_printable_only(column_or_name: ColumnOrName) -> ColumnChecks if the given column or string contains only printable characters.
Parameters
| Name | Type | Description |
|---|---|---|
column_or_name | ColumnOrName | The column or string to be checked. |
Returns
ColumnColumn- A column of boolean values indicating whether each entry contains only printable characters.
is_two_character_onlyfunction#
def is_two_character_only(column_or_name: ColumnOrName) -> ColumnChecks if the given column or string contains exactly two alphabetic characters (either lowercase or uppercase).
Parameters
| Name | Type | Description |
|---|---|---|
column_or_name | ColumnOrName | The column or string to be checked. |
Returns
ColumnColumn- A boolean column indicating whether the input matches the pattern of exactly two alphabetic characters.
startswithsfunction#
def startswiths(column_or_name: ColumnOrName, list_of_strings: list[str]) -> pyspark.sql.ColumnCreates a PySpark Column expression to check if the given column starts with any string in the list.
Parameters
| Name | Type | Description |
|---|---|---|
column_or_name | ColumnOrName | The column to check. |
list_of_strings | List[str] | A list of strings to check if the column starts with. |
Returns
Columnpyspark.sql.Column- A PySpark Column expression that evaluates to True if the column starts with any string in the list, otherwise False.