PyToolz:用python做大规模流数据分析
jopen
10年前
PyToolz:用python做大规模流数据分析。PyToolz是一组实用功能的迭代器,函数和字典的集合。
>>> def stem(word): ... """ Stem word to primitive form """ ... return word.lower().rstrip(",.!:;'-\"").lstrip("'\"") >>> from toolz import compose, frequencies, partial >>> wordcount = compose(frequencies, partial(map, stem), str.split) >>> sentence = "This cat jumped over this other cat!" >>> wordcount(sentence) {'this': 2, 'cat': 2, 'jumped': 1, 'over': 1, 'other': 1}