![](/img/trans.png)
[英]How to filter alphabetic values from a String column in Pyspark Dataframe?
[英]How to output column values from pyspark dataframe into string?
我正在使用數據集,並想創建一個名為'text'的特定列的所有值的textblob。 我嘗試了以下方法:
xp = positive.select("text").collect().map(_(0)).toList
#positive is the dataframes name, 'text' is the column name
xp = " ".join(positive['text])
到目前為止,這些方法都沒有對我有用,並且返回錯誤
'list' object has no attribute 'map'
Traceback (most recent call last):
AttributeError: 'list' object has no attribute 'map'
您似乎正在使用Scala語法。 collect
返回的list
包含Row
對象; 您可以使用生成器表達式簡單地訪問每個Row
的text
屬性,而不是使用map
(在任何情況下都不是list
的方法):
' '.join(row.text for row in positive.select('text').collect())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.