Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

how to apply pivot function of python to pyspark dataframe

I have a very big data but for illustration I am showing simplified version given below:

weekid type amount
1       A    10   
1       B    20
1       C    30
1       D    40
1       F    50

2       A    70
2       E    80
2       B    100

I am looking for a pivot function similar to python pandas, that gives a table below:

weekid type_A type_B type_C type_D type_E type_F
    1    10    20      30     40     0     50
    2    70    100     0      0      80    0 

Can you please help me to convert my first table to second one for pyspark dataframe? Thanks.

question from:https://stackoverflow.com/questions/65835015/how-to-apply-pivot-function-of-python-to-pyspark-dataframe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...