回答編集履歴
3
Update
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
r = r[:2] + [
|
34
34
|
|
35
|
-
r[i+2] *
|
35
|
+
r[i+2] * any((all(r[i:(i+2)]), all(r[(i+3):(i+5)])))
|
36
36
|
|
37
37
|
for i in range(l-4)
|
38
38
|
|
@@ -42,7 +42,7 @@
|
|
42
42
|
|
43
43
|
# 上の行も下の行も0なら0にする
|
44
44
|
|
45
|
-
r = r[:1] + [r[i+1] *
|
45
|
+
r = r[:1] + [r[i+1] * any((r[i], r[i+2])) for i in range(l-2)] + r[-1:]
|
46
46
|
|
47
47
|
|
48
48
|
|
2
Update
test
CHANGED
@@ -20,41 +20,35 @@
|
|
20
20
|
|
21
21
|
})
|
22
22
|
|
23
|
-
|
23
|
+
|
24
24
|
|
25
25
|
r = df['記録値'].tolist()
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
# 「該当行の上2行のいずれかが0かつ下2行のいずれかが0なら0にする」
|
30
|
-
|
31
|
-
|
27
|
+
l = len(r)
|
32
|
-
|
33
|
-
for i in range(l-4):
|
34
|
-
|
35
|
-
x, v, y = r[i:(i+2)], r[i+2], r[(i+3):(i+5)]
|
36
|
-
|
37
|
-
rr.append(v * (not ((0 in x) and (0 in y))))
|
38
|
-
|
39
|
-
rr += r[-2:]
|
40
28
|
|
41
29
|
|
42
30
|
|
43
|
-
#
|
31
|
+
# 該当行の上2行のいずれかが0かつ下2行のいずれかが0なら0にする
|
44
32
|
|
45
|
-
r
|
33
|
+
r = r[:2] + [
|
46
34
|
|
47
|
-
|
35
|
+
r[i+2] * (not ((0 in r[i:(i+2)]) and (0 in r[(i+3):(i+5)])))
|
48
36
|
|
49
|
-
|
37
|
+
for i in range(l-4)
|
50
38
|
|
51
|
-
|
39
|
+
] + r[-2:]
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
# 上の行も下の行も0なら0にする
|
44
|
+
|
45
|
+
r = r[:1] + [r[i+1] * bool(r[i] or r[i+2]) for i in range(l-2)] + r[-1:]
|
52
46
|
|
53
47
|
|
54
48
|
|
55
49
|
# データフレームに反映
|
56
50
|
|
57
|
-
df['記録値'] = r
|
51
|
+
df['記録値'] = r
|
58
52
|
|
59
53
|
|
60
54
|
|
1
Update
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
x, v, y = r[i:(i+2)], r[i+2], r[(i+3):(i+5)]
|
36
36
|
|
37
|
-
rr.append(
|
37
|
+
rr.append(v * (not ((0 in x) and (0 in y))))
|
38
38
|
|
39
39
|
rr += r[-2:]
|
40
40
|
|
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
for i in range(l-2):
|
48
48
|
|
49
|
-
rrr.append(
|
49
|
+
rrr.append(rr[i+1] * bool(rr[i] or rr[i+2]))
|
50
50
|
|
51
51
|
rrr += rr[-1:]
|
52
52
|
|