0
感激,如果有人可以在下面的代碼片段問題提供一些線索現在火花+蟒蛇+過濾問題
lineStr= sc.textFile("/input/words.txt")
print (lineStr.collect())
['this file is created to count the no of texts', 'other wise i am just doing fine', 'lets see the output is there']
wc = lineStr.flatMap(lambda l: l.split(" ")).map(lambda x: (x,1)).reduceByKey(lambda w,c: w+c)
print (wc.glom().collect())
[[('this', 1), ('there', 1), ('i', 1), ('texts', 1), ('just', 1), ('fine', 1), ('is', 2), ('other', 1), ('created', 1), ('count', 1), ('of', 1), ('am', 1), ('no', 1), ('output', 1)], [('lets', 1), ('see', 1), ('the', 2), ('file', 1), ('doing', 1), ('wise', 1), ('to', 1)]]
當我試圖篩選上述數據計數值設定超過1以下使用,我是收到錯誤
s = wc.filter(lambda a,b:b>1)
print (s.collect())
error : vs = list(itertools.islice(iterator, batch))
TypeError:() missing 1 required positional argument: 'b'
由於用於說明後面以及邏輯。它運行良好。 – Suraj
@Suraj,如果你認爲它回答了你的問題,請考慮[接受](http://meta.stackexchange.com/a/5235)答案 – MaxU