Map all columns of your Spark DataFrame whose name ends 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, ends_with() is used to define which columns spark_map() will apply the given function to. This function performs the inverse process of starts_with(), i.e. it searches for all columns whose name ends with a specific text. So, with the expression ends_with("Score"), ends_with() will map all columns whose name ends with the text "Score".
During the mapping process, an exact match between the searched strings is always used. As a result, an expression like ends_with("Sales") is not able to map columns like "brazil_sales", "colombia_sales" and "eua_sales", however it is able to map columns like "france_Sales " and "russia_Sales". If you need to be more flexible in your mapping, you’ll likely want to use the matches() function instead of ends_with().