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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -