cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.