spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Cheung <felixcheun...@hotmail.com>
Subject Re: Substitute Certain Rows a data Frame using SparkR
Date Wed, 19 Oct 2016 07:20:48 GMT
It's a bit less concise but this works:

> a <- as.DataFrame(cars)
> head(a)
  speed dist
1 4 2
2 4 10
3 7 4
4 7 22
5 8 16
6 9 10

> b <- withColumn(a, "speed", ifelse(a$speed > 15, a$speed, 3))
> head(b)
  speed dist
1 3 2
2 3 10
3 3 4
4 3 22
5 3 16
6 3 10

I think your example could be something we support though. Please feel free to open a JIRA
for that.
_____________________________
From: shilp <tshilpi@hotmail.com<mailto:tshilpi@hotmail.com>>
Sent: Monday, October 17, 2016 7:38 AM
Subject: Substitute Certain Rows a data Frame using SparkR
To: <user@spark.apache.org<mailto:user@spark.apache.org>>


I have a sparkR Data frame and I want to Replace certain Rows of a Column which satisfy certain
condition with some value.If it was a simple R data frame then I would do something as follows:df$Column1[df$Column1
== "Value"] = "NewValue" How would i perform similar operation on a SparkR data frame. ??
________________________________
View this message in context: Substitute Certain Rows a data Frame using SparkR<http://apache-spark-user-list.1001560.n3.nabble.com/Substitute-Certain-Rows-a-data-Frame-using-SparkR-tp27912.html>
Sent from the Apache Spark User List mailing list archive<http://apache-spark-user-list.1001560.n3.nabble.com/>
at Nabble.com<http://Nabble.com>.



Mime
View raw message