Reputation: 4650
The following code works:
likertRoundDfSeq:Seq[DataFrame] = ......
likertRoundDfSeq match
{
case head :: tail => tail.foldLeft(head){(dforg,df1)=>
DataFrameUtils.join(dforg,devianceFromAverageOneRound(df1),"A_RowId")
}
}
BUT, I need to add an index as an additional argument to devianceFromAverageOneRound
I thought of doing this with zipWithIndex
Perhaps, like this:
likertRoundDfSeq match
{
case head :: tail => tail.zipWithIndex.foldLeft(head){(dforg,df1)=>
DataFrameUtils.join(dforg,devianceFromAverageOneRound(df1,*myzipindex*),"A_RowId" )
}
}
But I am not sure how to break out the dataframe and idx in this case. Intellij does not seem to guide me on this, so I'm a bit lost
Any advice would be appreciated
Upvotes: 1
Views: 940
Reputation: 22439
The tail of your DF Seq is now a list of Tuple2[DataFrame, Long], hence your foldLeft
should look like the following:
case head :: tail => tail.zipWithIndex.foldLeft(head){ (dforg, df1) =>
DataFrameUtils.join(dforg, devianceFromAverageOneRound(df1._1, df1._2), "A_RowId")
This assumes your new devianceFromAverageOneRound(DataFrame, Long)
still returns a DataFrame
(and not Tuple2[DataFrame, Long]
).
Upvotes: 2