<jupyter_start><jupyter_text>CounterCounter是一个简单的计数器，在很多使用到dict统计次数的场景下，Counter来实现会非常简洁，效率也会很高<jupyter_code>from collections import Counter
c = Counter()
c
c = Counter("ddjvhdsvh")
c
import pdir
pdir(Counter())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10416666666666667, 'fraction_numerical': 0.0, 'mean_word_length': 15.066666666666666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '431181', 'license': 'Apache-2.0', 'n_tokens_mistral': 120, 'n_tokens_neox': 121, 'n_words': 13, 'path': 'python/python101/built-in-packages/07-collections.ipynb', 'repo_name': 'GmZhang3/data-science-ipython-notebooks', 'size': '240'}