For example, I want to plus the la and lon column and output result in another column.
+------+------------------+------------------+ |userid| la |
If you just need to sum two columns together, it's pretty straightforward :
df.withColumn("x", $"la" + $"lon")
x is the name of the new column.
To elevate the column into the power of 2 :
df.withColumn("x", pow($"la" + $"lon", 2))