python 2.7 - Keeping duplicates and deleting rest from pandas dataframe -
i have 3 different pandas dataframe, have concatenated. keep rows appear in 3 columns , delete rest. instance
column1 column2 column3 0 john sam 1 sam b rob 2 daniel c john 3 varys d ella
i want keep rows in column1
, appear in both column1
, column2
. in above example row -- 0 & 1.
desired output
column1 column2 0 john 1 sam b
filter df pass series 'column3'
arg isin
test membership:
in [42]: df[df['column1'].isin(df['column3'])] out[42]: column1 column2 column3 0 john sam 1 sam b rob
Comments
Post a Comment