import pandas as pd
person = {
"first": ["Kushagra", "Jane", "John"],
"last": ["Gupta", "Doe", "Doe"],
"email": ["Kushagra225@gmail.com", "JaneDoe123@gmail.com", "John@gmail.com"]
}
df = pd.DataFrame(person)
df
df['last'] == 'Doe'
#making filter
filt = (df['last'] == 'Doe')
#applying filter
df[filt]
#another way for applying filter
df.loc[filt]
#applying filter and get particular column using loc
df.loc[filt, 'email']
# & - and , | - or
#using and
filt = (df['last'] == 'Doe') & (df['first'] == 'John')
df.loc[filt]
#using or
filt = (df['last'] == 'Doe') | (df['first'] == 'John')
df.loc[filt]
#using negation (~) (opposite of normal output)
df.loc[~filt]
#applying filter from list
first_name = ['Jane', 'John']
filt = df['first'].isin(first_name)
df.loc[filt]