I have a dataframe in which I am only trying the parse the source files if all 5 mandatory columns(D1,D2,D3,D4,D5) exist. Currently, the problem is I am getting the attribute error when D4 or D5 does not exist. Can someone please guide me?
fp_wmuf_df = fp_wmuf_df.select(
fp_wmuf_df.D1,
fp_wmuf_df.D2,
translate(result_dict)(fp_wmuf_df.D3).alias("D3"),
regexp_replace(fp_wmuf_df.D4, "/", "-slash-").alias("D4"),
date_format(to_timestamp(fp_wmuf_df.D5 / 1000), "yyyy-MM-dd HH:mm:ss.SSSX").alias("D5"),
lit("").alias("result"),
)
Tried a few solutions but nothing worked