How to add new column of gender male as and female as 1

 
cognizant
How to add new column of gender male as  and female as 1


df = spark.read.format("csv").option("header","True").load("file:////home/cloudera/namegen.txt")

df.show()


dfc = df.withColumn("status",expr("case when gender='male' then 0 else 1 end"))

dfc.show()

Comments