2

How to add a string value to a column in pyspark. Using withColumn("status","online") gives error

I'm using Spark 1.6 here

Cœur
  • 37,241
  • 25
  • 195
  • 267
Sai N
  • 21
  • 1
  • 3

1 Answers1

-1

A new column can be added like below

df.withColumn("status",df.online)

This can be casted to string type explicitly like below

df.withColumn("status",df.online.cast("String"))
vishnuvr
  • 29
  • 4