Map all columns of your Spark DataFrame whose name starts with a specific text. This function is one of several existing mapping functions (read the article “Building the mapping”).
Arguments
text: a string containing the text you want to search for;
Details and examples
Therefore, starts_with() is used to define which columns spark_map() will apply the given function to. This function performs the inverse process of ends_with(), that is, it searches for all columns whose name starts with a specific text. Therefore, with the expression starts_with("Score"), starts_with() will map all columns whose name starts with the text "Score".
During the mapping process, an exact match between the searched strings is always used. As a result, an expression like starts_with("Sales") is not able to map columns like "sales_brazil", "sales_colombia" and "sales_eua", however it is able to map columns like "Sales_france " and "Sales_russia". If you need to be more flexible in your mapping, you’ll likely want to use the matches() function instead of starts_with().