I am trying to select all the rows which contain the name 'bil', or 'bob', preferably without writing out each condition (avoiding this: df2[df2['name']=='bil'|df2['name']=='bob']
). I thought the in
operator would work here, but it doesnt seem to. Are there any easier ways to do this?
d = {'name':['bil','bil','bil','jim'],
'date': ['2018-02-27 14:55:29', '2018-03-27 15:55:29', '2018-02-28 19:55:29','2018-02-28 19:55:29'],
'col2': [3,'', 4,''],
'col3': [1,2,3,55]
}
df2 = pd.DataFrame(data=d)
df2[df2['name'] in ['bil','bob']]