Dataframe Pyspark withColumn Issue

Hi

I am getting issue (‘DataFrame’ object is not callable) while trying withColumn on dataframe in Pyspark

peopleDF.withColumn(“year_test”,peopleDF(“count”)+10).show()

Traceback (most recent call last): File “<stdin>”, line 1, in <module>TypeError: ‘DataFrame’ object is not callable

Also getting issue (not defined lit) while using lit function with withColumn

Jupyter Issue:

peopleDF.withColumn(“new_column”,
when(peopleDF(“age”) == 29 , “A”)
.when(peopleDF(“age”) == 30 , “B”)
.otherwise(“C”))
.show()

Name: Compile Error
Message: :44: error: not found: value when
when(peopleDF(“age”) == 29 , “A”)
^

Could you please help.

Thanks

Hi @mearupmukherjee

The error is self-explanatory.

Could you please check your code once.