-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrap.py
More file actions
50 lines (34 loc) · 1.14 KB
/
scrap.py
File metadata and controls
50 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'^01 |02 |03 |04 |05 |06 |07 |08 |09 |010 |011 |012 |013 |014 |015 |016 |017 |18 |19 |20 |021 |022 |023 |024 |025 |026 |027 |028 |029 |030 |031 |032 |033 |034 |035 |036 |037 |038 |039 |040 |041 |042 |043 |044 |045 |046 |047'
def get_similar(X):
ids = X.index
text = [x.split(" ") for x in X.text]
m = len(map(len, text))
Names = []
for i in range(m):
name = set([x[i] for x in text])
n = len(name)
if n == 1:
Names.append(name.pop())
else:
return " ".join(Names)
return " ".join(Names)
def get_names(X):
name = get_similar(X)
i = X["index"]
return zip(i, repeat(name, len(i)))
def make_number(x):
try:
return int(x)
except:
return x
def get_max_min(X):
res = [x for x in X.values]
res1 = filter(lambda x: isinstance(x[-1], int), res)
if len(res1) > 1:
Max = max(res1, key=lambda x: x[-1])
Min = min(res1, key=lambda x: x[-1])
return [Max, Min]
elif len(res1) == 1:
return {"max": res1[0]}
elif len(res1) == 0 and len(res) == 1:
return res