I have a dataframe like:
Name_Index City_Index
2.0 1.0
0.0 2.0
1.0 0.0
I have a new list of values.
list(1.0,1.0)
I want to add these values to a new row in dataframe in the case that all previous rows are dropped.
My code:
val spark = SparkSession.builder
.master("local[*]")
.config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.getOrCreate()
var data = spark.read.option("header", "true")
.option("inferSchema", "true")
.csv("src/main/resources/student.csv")
val someDF = Seq(
(1.0,1.0)
).toDF("Name_Index","City_Index")
data=data.union(someDF).show()
It show output like:
Name_Index City_Index
2.0 1.0
0.0 2.0
1.0 0.0
1.1 1.1
But output should be like this. So that all the previous rows are dropped and new values are added.
Name_Index City_Index
1.0 1.0