【发布时间】:2018-07-21 22:46:46
【问题描述】:
我有以下 pyspark 数据框 (testDF=ldamodel.describeTopics().select("termIndices").toPandas())
topic| termIndices| termWeights|
+-----+---------------+--------------------+
| 0| [6, 118, 5]|[0.01205522104545...|
| 1| [0, 55, 100]|[0.00125521761966...|
我有以下单词列表
['one',
'peopl',
'govern',
'think',
'econom',
'rate',
'tax',
'polici',
'year',
'like',
........]
我正在尝试将 vocablist 匹配到 termIndices 到 termWeights。
到目前为止,我有以下内容:
for i in testDF.items():
for j in i[1]:
for m in j:
t=vocablist[m],m
print(t)
导致:
('tax', 6)
('insur', 118)
('rate', 5)
('peopl', 1)
('health', 84)
('incom', 38)
('think', 3)
('one', 0)
('social', 162)
.......
但我想要类似的东西
('tax', 6, 0.012055221045453202)
('insur', 118, 0.001255217619666775)
('rate', 5, 0.0032220995010401187)
('peopl', 1,0.008342115226031033)
('health', 84,0.0008332053105123403)
('incom', 38, ......)
任何帮助将不胜感激。
【问题讨论】: