score:1

Accepted answer

when you call .head on a dataframe you are returning a row.

if you look at the size of list1 you will see it only contains a single element.

you need to extract the string at element 0 of the row:

df
  .filter($"number"===1)
  .select($"letters")
  .head
  .getstring(0)
  .split(",")
  .zipwithindex

Related Query

More Query from same tag