python - pandas equivalent of SELECT * FROM table WHERE column1=column2 -


what pandas equivalent of 'select * table column1=column2'?

you have dataframe, 2 columns values. want rows numbers in both columns same. what's code that?

dataframe: column1   column2        b b        c        c d        d        b        b  result want: column1   column2 c        c d        d 

thank you.

in case, use pandas called masking

basically, dataframe[condition, on column or entire dataframe itself] returns dataframe condition true.

import pandas pd import numpy np  data = {'a':np.random.randint(0, 10, 100),        'b':np.random.randint(0, 10, 100)}  df = pd.dataframe(data) df[df.a==df.b] 

Comments