0

I have DataFrame like this(bat with 200 columns +):

uid sel_type1 sel_type2 sel_type3
123 1         0         1
123 1         1         0
100 0         1         2

and after i use

df.groupBy(col("uid")).sum()

i have something like this:

uid sum(sel_type1) sum(sel_type2) sum(sel_type3)
123 2              1              1
100 0              1              2

Bat i wont this:

uid sel_type1 sel_type2 sel_type3
123 2         1         1
100 0         1         2

How can i do it?

1

1 Answer 1

0

As seen here:

df.groupBy(col("uid")).sum().toDF(df.columns:_*)
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.