Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

How to update value of an dataframe if it satisfies a specific condition in spark scala

just need to know how can we update values inside a df with specific condition. If my approach is wrong please suggest one

while (i<myList.length-1)
{
    j=1
        while(j<myList.length)
        {
            result  = sqrt(pow(myList(i)- myList(j),2) + pow(myList2(i) - myList2(j),2))
            if(result>=3.4)
                df3.withColumn("New_Id", col("id")+1)  // if the coundition satisfies I need to update the new value as 1,2,3, .... in the New_id column
           j=j+1;      
        }
    i=i+1
}

df3.show(10) }


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

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...