How to GROUPBY a segment of variables considered as a sequence in Pyspark?

Viewed 38

I have two variables, X and Z such that Z is a segment of features (A sequence of features), Z= z1,z2,z3,... I would like to use "groupby" in PySpark to be able to run the following: groupBy(x,Z) The equivalent in Scala is as following but I don't know how to write the same thing in PySpark:

val xAndZSchema = x +: z
//Compute likelihood P(Z=z|X=x)
 val likelihoodDf = Df.groupBy(xAndZSchema.head, xAndZSchema.tail: _*)
 .agg(sum(lit(1)).alias("segment_count"))

What could I use instead of :_* in PySpark to consider the whole segment as a sequence?

0 Answers
Related