What is wrong with my code, I am using pyspark to convert a data type of a column.
company_df=company_df.withColumn("Revenue" ,company_df("Revenue").cast(DoubleType())) \
.withColumn("GROSS_PROFIT",company_df("GROSS_PROFIT").cast(DoubleType())) \
.withColumn("Net_Income" ,company_df("Net_Income").cast(DoubleType())) \
.withColumn("Enterprise_Value" ,company_df("Enterprise_Value").cast(DoubleType())) \
I am getting error as :
AttributeError: 'DataFrame' object has no attribute 'cast'
company_df("Revenue")to throw a callable error, however did you also trycompany_df["Revenue"].cast(DoubleType())inside the withColumn?