4

I have a pySpark dataframe and a list of floating point numbers. The list has the same number of elements as the number of rows. I would like to add this list as a new column to an existing dataframe.

I tried using withColumn like this:

df.withColumn('newColumn', newList)

But it didn't work. Is there a straightforward way to do so?

Thanks a lot for your help in advance.

soulless
  • 383
  • 1
  • 5
  • 18

0 Answers0