Skip to content
Advertisement

Spread List of Lists to Sparks DF with PySpark?

I’m currently struggling with following issue:

Let’s take following List of Lists:

JavaScript

How can I create following Sparks DF out of it with one row per element of each sublist:

JavaScript

The only way I’m getting this done is by processing this list to another list with for-loops, which basically then already represents all rows of my DF, which is probably not the best way to solve this.

THX & BR IntoNumbers

Advertisement

Answer

You can create a dataframe and use explode and array_min to get the desired output:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement