There is a "grass" Pandas dataframe: pid Name Class 1 Class 2 HP Attack Defense Sp. Atk Sp. Def Speed Legendary 0 1 Bulbasaur Grass Poison 45 49 49 65 65 45 False 1 2 Ivysaur Grass Poison 60 62 63 80 80 60 False 2 3 Venusaur Grass Poison 80 82 83 100 100 80 False 3 4 Mega Venusaur Grass Poison 80 100 123 122 120 80 False 48 49 Oddish Grass Poison 45 50 55 75 65 30 False Write a function that will search for 'Rock' values in the Class 1 and Class 2 columns. And if it finds such values it will delete these rows.
def search_data(data, search_word): for i in range(len(data)): if search_word in data.loc[i, 'Class 1'] or search_word in data.loc[i, 'Class 2']: data = data.drop([i]) return data search_data(grass, 'Rock')