Here's the code to programatically expand the DataFrame (keep reading to see all the steps broken down individually): keys_df = df.select(F.explode(F.map_keys(F.col("some_data"))).distinct() keys = list(map(lambda row: row[0], keys_df.collect())) key_cols = list(map(lambda f...