回答編集履歴
1
コードを一部変更
answer
CHANGED
@@ -19,8 +19,8 @@
|
|
19
19
|
df_duplicated_all = df[df.duplicated(keep=False)]
|
20
20
|
|
21
21
|
# 全カラムを使ってgroupbyして、それぞれのグループのインデックスをリストで抽出
|
22
|
-
output = [list(d.index)
|
23
|
-
|
22
|
+
groups = df_duplicated_all.groupby(list(df_duplicated_all.columns), as_index=False)
|
23
|
+
output = [list(d.index) for _, d in groups]
|
24
24
|
|
25
25
|
print(output)
|
26
26
|
# [[0, 5, 6], [4, 7]]
|