Spark with scala
My Product data frame looks like
Product countnum
+----------------+----------------+
|Resistor | 2|
|Capacitor | 2|
|Inductor | 3|
+----------------+----------------+
i am trying to get overall percentage like below:-
Product countnum Overall Profit
+----------------+----------------+--+----------------+
|Resistor | 2|28%-- 2/7*100(Here 7 is total countnum)
|Capacitor | 2|28%-- 2/7*100(Here 7 is total countnum)
|Inductor | 3|42.85%-- 3/7*100(Here 7 is total countnum)
+----------------+----------------+--+----------------+
Code:
val df = newdf.select("countnum"/(sum("countnum") as("percentage") ,"product","countnum",)
but it is giving error as "cannot resolve overloaded method 'select'
am i missing something here?