Use parameter duplicated
with keep=False
for all dupe rows and then groupby
by all columns and convert index values to tuples, last convert output Series
to list
:
df = df[df.duplicated(keep=False)]
df = df.groupby(list(df)).apply(lambda x: tuple(x.index)).tolist()
print (df)
[(1, 6), (2, 4), (3, 5)]
If you want also see duplicate values:
df1 = (df.groupby(df.columns.tolist())
.apply(lambda x: tuple(x.index))
.reset_index(name='idx'))
print (df1)
param_a param_b param_c idx
0 0 0 0 (1, 6)
1 0 2 1 (2, 4)
2 2 1 1 (3, 5)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…