您可以对值进行排序,然后
groupby:
a= np.sort(df.to_numpy(), axis=1)df.groupby([a[:,0], a[:,1]], as_index=False, sort=False).first()
选项2 :如果您有很多双
c1,c2,
groupby可能会很慢。在这种情况下,我们可以分配新值并按以下条件过滤
drop_duplicates:
a= np.sort(df.to_numpy(), axis=1)(df.assign(one=a[:,0], two=a[:,1]) # one and two can be changed .drop_duplicates(['one','two']) # taken from above .reindex(df.columns, axis=1))



