Camel to snake
Class for converting DataFrame column names from camel case to snake case.
koheesio.spark.transformations.camel_to_snake.camel_to_snake_re
module-attribute
#
camel_to_snake_re = compile('([a-z0-9])([A-Z])')
koheesio.spark.transformations.camel_to_snake.CamelToSnakeTransformation #
Converts column names from camel case to snake cases
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns
|
Optional[ListOfColumns]
|
The column or columns to convert. If no columns are specified, all columns will be converted. A list of columns
or a single column can be specified.
For example: |
None
|
Example
input_df:
camelCaseColumn | snake_case_column |
---|---|
... | ... |
output_df:
camel_case_column | snake_case_column |
---|---|
... | ... |
In this example, the column camelCaseColumn
is converted to camel_case_column
.
Note: the data in the columns is not changed, only the column names.
columns
class-attribute
instance-attribute
#
columns: Optional[ListOfColumns] = Field(
default="",
alias="column",
description="The column or columns to convert. If no columns are specified, all columns will be converted. A list of columns or a single column can be specified. For example: `['column1', 'column2']` or `'column1'` ",
)
koheesio.spark.transformations.camel_to_snake.convert_camel_to_snake #
Converts a string from camelCase to snake_case.
Parameters:
name : str The string to be converted.
Returns:
str The converted string in snake_case.