我正在使用mrjob库在python中编写mapreducer。我安装了mrjob包,但是当我Sub Macro1()
'
' Macro1 Macro
'
'
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.ApplyChartTemplate ( _
"C:\Users\Username\AppData\Roaming\Microsoft\Templates\Charts\WhatYouNamedTheTemplate.crtx")Sheet1!$A$1:$C$4
ActiveChart.SetSourceData Source:=Range("SheetWhereDataIs!RangeYouWantChartToBeCreatedFrom EX:Sheet1!$A$1:$C$4")
End Sub
时出现错误:
from mrjob.step import MRStep
任何人都可以帮助我吗?非常感谢
答案 0 :(得分:0)
大家好我解决了这个问题,这里是字数的工作代码。从本质上讲,一个简单的替代对我有用。
来自mrjob.job导入MRJob 导入重新
WORD_RE = re.compile(r" [\ w'] +")
类MRMostUsedWord(MRJob):
def mapper_get_words(self, _, line):
# yield each word in the line
for word in WORD_RE.findall(line):
yield (word.lower(), 1)
def combiner_count_words(self, word, counts):
# sum the words we've seen so far
yield (word, sum(counts))
def reducer_count_words(self, word, counts):
# send all (num_occurrences, word) pairs to the same reducer.
# num_occurrences is so we can easily use Python's max() function.
yield None, (sum(counts), word)
# discard the key; it is just None
def reducer_find_max_word(self, _, word_count_pairs):
# each item of word_count_pairs is (count, word),
# so yielding one results in key=counts, value=word
yield max(word_count_pairs)
def steps(self):
return [
self.mr(mapper=self.mapper_get_words,
combiner=self.combiner_count_words,
reducer=self.reducer_count_words),
self.mr(reducer=self.reducer_find_max_word)
]
如果名称 ==' 主要': MRMostUsedWord.run()