cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function When + Dictionary.

weldermartins
Honored Contributor

Hey everyone, I'm avoiding repeating the When Function for 12x, so I thought of the dictionary. I don't know if it's a limitation of the Spark function or a Logic error. Does the function allow this concatenation?

image

1 ACCEPTED SOLUTION

Accepted Solutions

weldermartins
Honored Contributor

Hello everyone, I found this alternative to reduce repeated code.

custoDF = (custoDF.withColumn('month', col('Nummes').cast('string'))
        .replace(months, subset=['month']))

image

View solution in original post

3 REPLIES 3

weldermartins
Honored Contributor

@Werner Stinckens​,  @pat​, @Hubert Dudek​   Have you ever done something similar?

Tromen026
New Contributor II

I have read some good stuff here. Certainly price bookmarking for revisiting.

little caesars pizza prices

braums menu with prices

weldermartins
Honored Contributor

Hello everyone, I found this alternative to reduce repeated code.

custoDF = (custoDF.withColumn('month', col('Nummes').cast('string'))
        .replace(months, subset=['month']))

image