以下代码起作用
likertRoundDfSeq:Seq[DataFrame] = ......
likertRoundDfSeq match
{
case head :: tail => tail.foldLeft(head){(dforg,df1)=>
DataFrameUtils.join(dforg,devianceFromAverageOneRound(df1),"A_RowId")
}
}但是,我需要添加一个索引作为devianceFromAverageOneRound的附加参数
我想用zipWithIndex这样做,就像这样:
likertRoundDfSeq match
{
case head :: tail => tail.zipWithIndex.foldLeft(head){(dforg,df1)=>
DataFrameUtils.join(dforg,devianceFromAverageOneRound(df1,*myzipindex*),"A_RowId" )
}
}但在这种情况下,我不知道如何打破dataframe和idx。Intellij似乎没有在这方面指导我,所以我有点迷路了
如有任何建议,将不胜感激。
发布于 2018-06-11 20:51:00
DF的尾部现在是一个Tuple2DataFrame的列表,很长,因此您的foldLeft应该如下所示:
case head :: tail => tail.zipWithIndex.foldLeft(head){ (dforg, df1) =>
DataFrameUtils.join(dforg, devianceFromAverageOneRound(df1._1, df1._2), "A_RowId")这假设您的新devianceFromAverageOneRound(DataFrame, Long)仍然返回一个DataFrame (而不是Tuple2[DataFrame, Long])。
https://stackoverflow.com/questions/50804986
复制相似问题