'pyspark how to collect map keys into list

I have a dataframe with a map column. I want to collect the not null keys into a new column:

P1



Solution 1:[1]

You can use map_filter to filter the non null keys and then use map_keys which returns the keys as an array.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 walking