How to cast a WrappedArray[WrappedArray[Float]] to Array[Array[Float]] in spark (scala)

前端 未结 2 338
时光说笑
时光说笑 2020-12-20 18:10

Im using Spark 2.0. I have a column of my dataframe containing a WrappedArray of WrappedArrays of Float.

An example of a row would be:



        
相关标签:
2条回答
  • 2020-12-20 18:22

    Following @sami-badawi 's answer I am posting the answer for those like me who started from a dataframe.

    dataframe.select("mycolumn").rdd.map
    (row => row.get(0).asInstanceOf[WrappedArray[WrappedArray[Float]]].array.map(x=>x.toArray))
    
    0 讨论(0)
  • 2020-12-20 18:39

    Try this:

      val wawa: WrappedArray[WrappedArray[Float]] = null 
      val res: Array[Array[Float]] = wawa.map(inner => inner.array).toArray
    

    It compiles for me

    0 讨论(0)
提交回复
热议问题