Kind similar to this question: Pandas merge removing duplicate rows
I am using Python pandas -
Input:
df = pd.DataFrame({
'type':['a','b','c','d','e'],
'value':[100,200,300,400,500]})
I want to self-join this list:
df_merge = pd.merge(df, df,on=['type'])
But I want only want to keep rows below:
type_x value_x type_y value_y
a 100 b 200
a 100 c 300
a 100 d 400
a 100 e 500
b 200 c 300
b 200 d 400
b 200 e 500
c 300 d 400
c 300 e 500
d 400 e 500
How can I do this in Pandas? Thank you for the help!