Look at the code below. I have a df and in the first method i simple check for the existence of 'Ankit' in the entire dataframe and this works but the second method does'nt. why?
import pandas as pd
# dictionary with list object in values
details = {
'Name' : ['Ankit', 'Aishwarya', 'Shaurya',
'Shivangi', 'Priya', 'Swapnil'],
'Age' : [23, 21, 22, 21, 24, 25],
'University' : ['BHU', 'JNU', 'DU', 'BHU', 'Geu', 'Geu'],}
# creating a Dataframe object
df = pd.DataFrame(details, columns = ['Name', 'Age', 'University'],
index = ['a', 'b', 'c', 'd', 'e', 'f'])
print("Dataframe: \n\n", df)
# check 'Ankit' exist in dataframe or not
if 'Ankit' in df.values :
print("\nThis value exists in Dataframe")
if 'Ankit' in df['Name']:
print("\nThis value exists in Dataframe")
else:
print("not found")