这是我的 mongodb 集合的架构的一部分:
|-- variables: struct (nullable = true)
| |-- actives: struct (nullable = true)
| | |-- data: struct (nullable = true)
| | | |-- 0: struct (nullable = true)
| | | | |--active: integer (nullable = true)
| | | | |-- inactive: integer (nullable = true)
我已获取该集合并将其存储在 Spark 数据框中,现在正在尝试提取最里面的值变量 column.
df_temp = df1.select(df1.variables.actives.data)
这工作得很好,我能够得到内部结构data struct.
+----------------------+
|variables.actives.data|
+----------------------+
| [[1,32,0.516165...|
| [[1,30,1.173139...|
| [[4,18,0.160088...|
然而,当我尝试进一步深入时:
df_temp = df1.select(df1.variables.actives.data.0.active)
我得到一个无效的语法 error.
df_temp = df1.select(df1.variables.actives.data.0.active)
^
语法错误:语法无效
问题是我的内部字段键的名称是数字,并且我找不到内部字段键的名称是数字的示例。
实现我检索最内在价值的目标的最佳方法是什么(active and inactive)来自数据框?