import org.apache.spark.sql.functions._
val df = meta.core.DataCore.spark.createDataFrame(Seq(
(0, "+56.5"),
(1, "-64.83"),
(2, "+12.1234"),
(3, "13"),
(4, "-10.0"),
(5, "2"),
(6, "0")
)).toDF("id", "all_digitals")
df
.withColumn("not_decimals", when(col("all_digitals").contains("."), "").otherwise(col("all_digitals")))
.show()
Результат:
+---+------------+------------+
| id|all_digitals|not_decimals|
+---+------------+------------+
| 0| +56.5| |
| 1| -64.83| |
| 2| +12.1234| |
| 3| 13| 13|
| 4| -10.0| |
| 5| 2| 2|
| 6| 0| 0|
+---+------------+------------+