withColumn takes a column as the second argument, not string.
If you want formatting before show() you can use the round() function.
--
Raghavendra
On Mon, May 23, 2022 at 11:35 AM wilson wrote:
> hello
>
> how to add a column for percent for the current row of counted data?
>
&g
hello
how to add a column for percent for the current row of counted data?
scala>
df2.groupBy("_c1").count.withColumn("percent",f"${col(count)/df2.count}%.2f").show
:30: error: type mismatch;
This doesn't work.
so please help. thanks.