0

I am trying to manipulate dataframe using select in spark scala. I want to multiply column values by 10 using select but it fails. Also let me know how to perform map, flatmap, reducebykey operations on dataframe using select.

df1.select("Sales"*10,"Profit"*10).show()

df1.select("Sales").map(x=>x*10).show()

Help me to solve this issue! Thanks!

0

1 Answer 1

1

you should use col instead of string :

df1
.select
 (
  (col("Sales")*10).as("Sales"),
  (col("Profit")*10).as("Profit")
)
.show()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.