回答編集履歴
1
修正
answer
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
end_indices = df.index[df["col_4"] == "end_of_cat"]
|
6
6
|
|
7
7
|
for start, end in zip(start_indices, end_indices):
|
8
|
-
name = df.loc[start, "col_3"]
|
8
|
+
name = df.loc[start, "col_3"] # 名前を取り出す
|
9
|
-
df.loc[start + 1 : end, "col_6"] = name
|
9
|
+
df.loc[start + 1 : end, "col_6"] = name # 名前を設定する
|
10
10
|
|
11
11
|
ret = df.loc[df["col_1"] != "start", ["col_1", "col_2", "col_6"]]
|
12
12
|
ret
|