Enabler
ensure_column(*columns)
Enables PySpark functions to accept either column names (as strings) or Column objects.
Parameters: columns (ColumnOrName): Column names (as strings) or Column objects to be converted.
Returns: tuple[Column]: A tuple of Column objects.
Examples:
>>> ensure_column("col1", "col2", F.col("col3"))
(Column<b'col1'>, Column<b'col2'>, Column<b'col3'>)
Source code in pysparky/enabler.py
ensure_list(single_or_list)
Ensures the input is returned as a list.
If the input is not already a list, it wraps the input in a list. If the input is already a list, it returns the input unchanged.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
single_or_list
|
Union[Any, List[Any]]
|
The input which can be a single item or a list of items. |
required |
Returns:
Type | Description |
---|---|
list[Any]
|
List[Any]: A list containing the input item(s). |
Examples: