回答編集履歴
1
Update
answer
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
> クールな解答を待っています。
|
2
2
|
|
3
|
-
愚直に
|
3
|
+
愚直に?
|
4
4
|
|
5
5
|
```python
|
6
6
|
import pandas as pd
|
7
7
|
|
8
8
|
train_fa = pd.DataFrame({
|
9
9
|
'answers': [
|
10
|
-
{'
|
10
|
+
"[{'text': 'text 01', 'answer_start': 1}]",
|
11
|
-
{'
|
11
|
+
"[{'text': 'text 02', 'answer_start': 2}]",
|
12
|
-
{'
|
12
|
+
"[{'text': 'text 03', 'answer_start': 3}]",
|
13
|
-
{'
|
13
|
+
"[{'text': 'text 04', 'answer_start': 4}]",
|
14
|
-
{'
|
14
|
+
"[{'text': 'text 05', 'answer_start': 5}]",
|
15
15
|
],
|
16
16
|
})
|
17
17
|
|
18
|
-
train_fa.answers = train_fa.answers.apply(
|
18
|
+
train_fa.answers = train_fa.answers.apply(lambda x: x[1:-1])
|
19
|
-
lambda x: {k: v[0] for k, v in x.items()})
|
20
19
|
|
21
20
|
print(train_fa)
|
22
21
|
|
23
22
|
#
|
24
|
-
answers
|
25
|
-
0
|
23
|
+
0 {'text': 'text 01', 'answer_start': 1}
|
26
|
-
1
|
24
|
+
1 {'text': 'text 02', 'answer_start': 2}
|
27
|
-
2
|
25
|
+
2 {'text': 'text 03', 'answer_start': 3}
|
28
|
-
3
|
26
|
+
3 {'text': 'text 04', 'answer_start': 4}
|
29
|
-
4
|
27
|
+
4 {'text': 'text 05', 'answer_start': 5}
|
30
28
|
```
|