Skip to content

Commit 4224f33

Browse files
committed
initial
0 parents  commit 4224f33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+43917
-0
lines changed

.idea/.gitignore

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/Data_Science.iml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dataSources.xml

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/other.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Whitespace-only changes.

collections_module/__init__.py

Whitespace-only changes.
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#%%
2+
from collections import Counter
3+
4+
# for string
5+
a = 'aabbbbccc'
6+
print(Counter(a))
7+
8+
#for list
9+
a = [1,2,2,1,2,3,4,1,2,3,3,23,1,123]
10+
print(Counter(a))
11+
12+
#in order to get just the count number use .values()
13+
a = 'abbbbabbbbccc'
14+
# a = [1,2,2,1,2,3,4,1,2,3,3,23,1,123]
15+
16+
print(Counter(a).values())
17+
18+
#to get the most common used --> use .most_common(2)
19+
print(Counter(a).most_common(2))
20+
21+
# to get iterator of elements
22+
a = 'bbbabbbbabbbbccc'
23+
iterator = Counter(a).elements() # return the iterator where all same elements are ordered together
24+
print(list(iterator))
25+
26+
#%%
27+
28+
from collections import namedtuple
29+
30+
Points = namedtuple('Points', 'x,y')
31+
pt = Points(1,-4)
32+
print(pt)
33+
print(pt.x)
34+
print(pt.y)
35+
36+
#%%
37+
from collections import OrderedDict
38+
39+
# the orderedDict will remember the order in which data is inserted
40+
# but from python 3.7 onwards the default dict also remembers the order
41+
ordered_dict = OrderedDict()
42+
ordered_dict['a'] = 100
43+
ordered_dict['b'] = 120
44+
ordered_dict['c'] = 50
45+
ordered_dict['d'] = 180
46+
ordered_dict['e'] = 350
47+
48+
print(ordered_dict)
49+
50+
#%%
51+
from collections import defaultdict
52+
53+
# defaultdict is similar to normal dictionary but it will have default value
54+
55+
d = defaultdict(int) # you can also define the type you can use float, str, list etc. if the key does not exist then it
56+
# will create with default creation you have provided in defaultdict
57+
d['a'] = 100
58+
d['b'] = 120
59+
d['c'] = 50
60+
61+
print(d)
62+
print(d['m'])
63+
print(d) # if you try to access any value that is not in defaultl_dict then it will create a key and store default value
64+
65+
#%%
66+
from collections import deque
67+
68+
# can be used as queue where we can access value either from first or last
69+
70+
d = deque()
71+
d.append(1) # first element added
72+
d.append(2) # second element will be added to the right end
73+
74+
d.appendleft(4) # will be appended at the beginning
75+
print(d)
76+
77+
print(d.pop()) # will pop from the right end
78+
79+
print(d.popleft()) # will return and remove the element from the beginning
80+
81+
d.extend([1,2,3,4]) # will add all the elements at the right end
82+
d.extendleft([100,200,300]) # will add all the elements at the left end
83+
print('before rotation: ',d)
84+
d.rotate(1) # will rotate all the elements to the right by 1
85+
86+
# we can rotate to the left side as well by providing the negative number
87+
print('after rotation: ',d)
88+
89+
d.clear() # to clear
90+
91+
92+
#%%
93+
94+
from collections import ChainMap
95+
96+
# chainmap is used to combine multiple dictionaries to one dictionary
97+
98+
baseline = {'music': 'bach', 'art': 'rembrandt'}
99+
adjustments = {'art': 'van gogh', 'opera': 'carmen'}
100+
chainmap = ChainMap(adjustments, baseline)
101+
print(chainmap['music'])
102+

collections_module/islice_text

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
What is Lorem Ipsum?
2+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard
3+
dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
4+
book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially
5+
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
6+
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
7+
8+
Why do we use it?
9+
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its
10+
layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to
11+
using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web
12+
page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web
13+
sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on
14+
purpose (injected humour and the like).
15+
16+
17+
Where does it come from?
18+
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical
19+
Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at
20+
Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from
21+
a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the
22+
undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum"
23+
(The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics,
24+
very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a
25+
line in section 1.10.32.

data_science/arrayread.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Sanket Gupta, 26 , M
2+
Sanchita Gupta, 23 , F
3+
Medhavi Kulkarni, 24 , F
4+
Tushar Mahajan, 25, M
5+
Ritika, 22, F
6+
Meera Jain, 24, F

0 commit comments

Comments
 (0)