I have a large dataframe in which I need to check if a particular column (column_A) exist in dataframe and if the column exist then based on that some processing need to happen otherwise it has to do some other processing -
I am currently trying below -
try:
input_df = input_df.withColumn("column_A", input_df["column_A"].cast(StringType()))
Do some processing
except:
input_df = input_df.drop('column_B')
There must be a better way of achieving it. Thanks in advance