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['email']
#setting email as index
df.set_index('email')
#changes are not carried over
df
#inplace is used so changes are carried over
df.set_index('email', inplace=True)
df
df.index
#you can now use email as index in loc
df.loc['Kushagra225@gmail.com']
#reseting index
df.reset_index(inplace=True)
df