Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

return max value in groupby pyspark

from pyspark.sql import Window
w = Window.partitionBy('A')
df.withColumn('maxB', f.max('B').over(w))
    .where(f.col('B') == f.col('maxB'))
    .drop('maxB')
    .show()
#+---+---+
#|  A|  B|
#+---+---+
#|  a|  8|
#|  b|  3|
#+---+---+
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #return #max #groupby #pyspark
ADD COMMENT
Topic
Name
2+9 =