In Scala you can first define your columns, and then use the
list-to-vararg-expander :_* in a select call, something like this:
val cols = colnames.map(col).map(column => {
*lit(0)*
})
dF.select(cols: _*)
I assume something similar should be possible in Java as well, from
your snippet it's unc
Hi ,
How we can create multiple columns iteratively i mean how you can create
empty columns inside loop because :
with
for i in listl :
df = df.withcolumn(i,F.lit(0))
we get stackoverflow
how we can do that inside list of columns like that
df.select([F.col(i).lit(0) for i in df.columns