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

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group