Can you pass a pyspark column with index values into the element_at functions?
I have a df similar to the following:
------------------
foo | bar
------------------
1 | [3, 2, 1]
2 | [3, 3, 1]
1 | [8, 2, 1]
And I am trying to use the foo as the index to create the following:
baz |
--------
3 |
3 |
8 |
I am trying to use the following with no success:
df.withColumn('baz', F.element_at('bar', F.col('foo'))