我行RDD看起来是这样的:如何访问elemens横栏RDD在SCALA
Array[org.apache.spark.sql.Row] = Array([1,[example1,WrappedArray([**Standford,Organisation,NNP], [is,O,VP], [good,LOCATION,ADP**])]])
我从转换数据帧到RDD了这一点,数据帧的模式是:
root
|-- article_id: long (nullable = true)
|-- sentence: struct (nullable = true)
| |-- sentence: string (nullable = true)
| |-- attributes: array (nullable = true)
| | |-- element: struct (containsNull = true)
| | | |-- tokens: string (nullable = true)
| | | |-- ner: string (nullable = true)
| | | |-- pos: string (nullable = true)
现在怎么办在rowd中访问元素,在dataframe中我可以使用df.select(“sentence”)。我期待访问像斯坦福/其他嵌套元素的元素。
在'RDD [行]元素'是'的Row's。您可以像RDD [String]或RDD [Int]这样的其他RDD访问它们。 –
@ SarveshKumarSingh-你能告诉我如何访问pos的例子 –
如果给定的答案解决了你的问题,请接受它,否则评论为什么它为你工作! – eliasah