回答編集履歴
3
Update
answer
CHANGED
@@ -18,16 +18,12 @@
|
|
18
18
|
print(df.to_markdown(index=False))
|
19
19
|
|
20
20
|
#
|
21
|
-
replacer = (
|
22
|
-
|
21
|
+
df.iloc[:, :3] = (
|
23
|
-
|
22
|
+
df.apply(lambda x:
|
23
|
+
x[:3].replace(
|
24
|
-
|
24
|
+
{i[0]: ':'+i[1] for i in x[3:].str.split(':') if len(i)==2},
|
25
|
-
|
25
|
+
regex=True), axis=1))
|
26
26
|
|
27
|
-
df.iloc[:,:3] = (
|
28
|
-
df.iloc[:,:3]
|
29
|
-
.apply(lambda x: x.replace(replacer[x.name], regex=True), axis=1))
|
30
|
-
|
31
27
|
print(df.to_markdown(index=False))
|
32
28
|
```
|
33
29
|
|
2
Update
answer
CHANGED
@@ -21,13 +21,12 @@
|
|
21
21
|
replacer = (
|
22
22
|
df.loc[:, 3:]
|
23
23
|
.apply(lambda x:
|
24
|
-
|
24
|
+
{i[0]: ':'+i[1] for i in x.str.split(':') if len(i)==2},
|
25
|
-
|
25
|
+
axis=1))
|
26
26
|
|
27
27
|
df.iloc[:,:3] = (
|
28
28
|
df.iloc[:,:3]
|
29
|
-
.apply(lambda x: x.replace(replacer[x.name], regex=True),
|
29
|
+
.apply(lambda x: x.replace(replacer[x.name], regex=True), axis=1))
|
30
|
-
axis=1))
|
31
30
|
|
32
31
|
print(df.to_markdown(index=False))
|
33
32
|
```
|
1
Update
answer
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
replacer = (
|
22
22
|
df.loc[:, 3:]
|
23
23
|
.apply(lambda x:
|
24
|
-
{i[0]: i[1] for i in x.str.split(':') if len(i)
|
24
|
+
{i[0]: ':'+i[1] for i in x.str.split(':') if len(i)==2},
|
25
25
|
axis=1))
|
26
26
|
|
27
27
|
df.iloc[:,:3] = (
|
@@ -49,11 +49,11 @@
|
|
49
49
|
|
50
50
|
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|
51
51
|
|:----|:----|:----|:-----|:-----|:-----|:-----|:----|
|
52
|
-
|
|
52
|
+
| Q:a | B | K | ※1:a | | | | |
|
53
|
-
| Z |
|
53
|
+
| Z | J:b | U | ※1:b | | | | |
|
54
|
-
| L | S |
|
54
|
+
| L | S | Z:f | ※1:c | ※2:d | ※3:e | ※4:f | |
|
55
|
-
|
|
55
|
+
| G:g | N:h | Y:i | ※1:g | ※2:h | ※3:i | | |
|
56
56
|
| D | Z | G | | | | | |
|
57
|
-
|
|
57
|
+
| K:j | V | O | ※1:j | | | | |
|
58
|
-
| Y |
|
58
|
+
| Y | X:k | Y | ※1:k | | | | |
|
59
|
-
| X |
|
59
|
+
| X | I:l | S:m | ※1:l | ※2:m | | | |
|