java - Dividing the value of 2 columns in spark dataframe -


the table looks this

i have table in spark stored dataframe. want dataframe(url,url1,ratio) contains ratio,where ratio = count1/count in it. how write operation it?

it's straightforward :

import spark.implicits._ val newdf = df.withcolumn("ratio", $"count1" / $"count")  

this line of code add column named ration df , sotore result in newdf

edit 1 : (solution in java requested)

import org.apache.spark.sql.functions._ dataset<row> newdf = df.withcolumn("ration", col("count1").divide(col("count")) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -