result.txt↓
4 25.0
5 62.5
6-18 75.0
19-32 100.0
33 87.5
34-44 100.0
45-46 100.0
47 87.5
48-50 87.5
51 100.0
52 100.0
53-71 100.0
72 87.5
73-74 75.0
75-156 100.0
157-161 62.5
162 87.5
163-172 100.0
173-174 100.0
175-203 100.0
204 100.0
205-209 87.5
210-211 87.5
212-230 75.0
231 62.5
232 12.5
234 12.5
import pandas as pd data = pd.read_table('./result.txt', header=None ,names=('A', 'B')) print(data)
上記コードを実行して、結果が下記のようになります。
A B 0 4 25.0 NaN 1 5 62.5 NaN 2 6-18 75.0 NaN 3 19-32 100.0 NaN 4 33 87.5 NaN 5 34-44 100.0 NaN 6 45-46 100.0 NaN 7 47 87.5 NaN 8 48-50 87.5 NaN 9 51 100.0 NaN 10 52 100.0 NaN 11 53-71 100.0 NaN 12 72 87.5 NaN 13 73-74 75.0 NaN 14 75-156 100.0 NaN 15 157-161 62.5 NaN 16 162 87.5 NaN 17 163-172 100.0 NaN 18 173-174 100.0 NaN 19 175-203 100.0 NaN 20 204 100.0 NaN 21 205-209 87.5 NaN 22 210-211 87.5 NaN 23 212-230 75.0 NaN 24 231 62.5 NaN 25 232 12.5 NaN 26 234 12.5 NaN
本当は下記のように空白でAとBに分けたいのですが、どうしたらよいのでしょうか?
A B 0 4 25.0 1 5 62.5 2 6-18 75.0 3 19-32 100.0 4 33 87.5 5 34-44 100.0 6 45-46 100.0 7 47 87.5 8 48-50 87.5 9 51 100.0 10 52 100.0 11 53-71 100.0 12 72 87.5 13 73-74 75.0 14 75-156 100.0 15 157-161 62.5 16 162 87.5 17 163-172 100.0 18 173-174 100.0 19 175-203 100.0 20 204 100.0 21 205-209 87.5 22 210-211 87.5 23 212-230 75.0 24 231 62.5 25 232 12.5 26 234 12.5
回答1件
あなたの回答
tips
プレビュー