Columns are the different fields that contain their particular values when we create a DataFrame. We can perform certain operations on both rows & column values. Here, we are going to check the whether a value is present in a column or not.
Let us understand with the help of an example,
# Import pandas Package import pandas as pd # Creating dictionary d = { 'Name':['Ankit', 'Tushar', 'Saloni','Jyoti', 'Anuj', 'Rajat'], 'Age':[23, 21, 22, 21, 24, 25], 'University':['BHU', 'JNU', 'DU', 'BHU', 'Geu', 'Geu'] } # Creating a Dataframe df = pd.DataFrame(d,index = ['a', 'b', 'c', 'd', 'e', 'f']) print("Created Dataframe:\n", df) # check 'Jyoti' exist in DataFrame or not if 'Jyoti' in df.values : print("\nYes,'Jyoti' is Present in DataFrame") else : print("\nSorry!, This value does not exists in Dataframe")
Output:
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Let us understand with the help of an example,
Output:

need an explanation for this answer? contact us directly to get an explanation for this answer