<jupyter_start><jupyter_text><jupyter_code>from collections import Counter
lst = [1,2,2,2,2,3,3,3,1,2,1,12,3,2,32,1,21,1,223,1]

Counter(lst)
Counter('aabsbsbsbhshhbbsbs')
s = 'How many times does each word show up in this sentence word times each each word'

words = s.split()
print(words)
Counter(words)
c = Counter(words)

c.most_common(2)<jupyter_output><empty_output><jupyter_text>defaultdict<jupyter_code>from collections import defaultdict
d = {1: "ABC",2: "XYZ"}
d[1]
d[2]
d[3]
d1 = defaultdict(int)
d1['one'] = 1
d1['two'] = 2
d1['three']
d1 = defaultdict(str)
d1[1] = 'One'
d1[2] = 'Two'
d1[3]<jupyter_output><empty_output><jupyter_text>ordereddict<jupyter_code>from collections import OrderedDict
od = OrderedDict()
od['a'] = 1
od['b'] = 2
od['c'] = 3
od
od['a'] = 4
od<jupyter_output><empty_output><jupyter_text>deque<jupyter_code>from collections import deque
l = ["a","b","c"]
deq = deque(l)
deq
deq.append("d")
deq
deq.appendleft("x")
deq
deq.pop()
deq
deq.popleft()
deq
deq.count("c")
deq.append("a")
deq.count("a")<jupyter_output><empty_output><jupyter_text>ChainMap<jupyter_code>d1 = {'a':1, 'b' : 2}
d2 = {'c': 3, 'd': 4}
from collections import ChainMap
c_map = ChainMap(d1,d2)
c_map.maps
c_map['a']
c_map['c']
list(c_map.keys())
list(c_map.values())
d3 = {'e' : 5, 'f': 6}
c_map = c_map.new_child(d3)
c_map
c_map['a']
c_map['e']<jupyter_output><empty_output><jupyter_text>namedtuple<jupyter_code>from collections import namedtuple
Student = namedtuple('Student', 'fname, lname, age')
s1 = Student('Tom', 'Hanks', '60')
s1
s1.fname
s1.age
l = ['John', 'Wick', '50']
s2 = Student._make(l)
s2<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19146341463414634, 'fraction_numerical': 0.042682926829268296, 'mean_word_length': 7.682539682539683, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '513281', 'license': 'Apache-2.0', 'n_tokens_mistral': 776, 'n_tokens_neox': 752, 'n_words': 141, 'path': 'SESSION12_(Collections).ipynb', 'repo_name': 'madhavjk/CP-Python', 'size': '1640'}