Answer by Nav for How to convert column values from string to decimal?
In scala-spark you can use the DecimalType for conversion:import org.apache.spark.sql.types.DecimalTypeval convertedDf = dframe.withColumn("c_number",trim(col("c_a")).cast(DecimalType(20,0)))
View ArticleAnswer by Protyush Ghosh for How to convert column values from string to...
In scala :df=df.withColumn("col", $"col".cast(DecimalType(9,2)))
View ArticleAnswer by Sesha for How to convert column values from string to decimal?
This is after you have data in data frame with column that needs to be converted is readyTry:dframe.select($"column_name".cast("decimal(9,2)"))
View ArticleAnswer by Fabich for How to convert column values from string to decimal?
A Decimal has a precision and scale value, by default the precision is 10 and scale is 0.The precision is the maximum number of digit in your number. In your case you have more than 10 digits so the...
View ArticleAnswer by user6022341 for How to convert column values from string to decimal?
Try:dframe.withColumn("c_number", dframe.col("c_a").cast("decimal(38,0)"))
View ArticleHow to convert column values from string to decimal?
I'm having a dataframe which contains a really big integer value, example:42306810747081022358When I've tried to convert it to long it was working in the Java but not under the spark envrironment, I...
View Article