I have a data frame, want to create a column based on the string in column1_sport.
import pandas as pd
df = pd.read_csv('C:/Users/test/dataframe.csv', encoding = 'iso-8859-1')
Data contains:
column1_sport
baseball
basketball
tennis
boxing
golf
I want to look for certain strings ("ball" or "box") and create a new column based on whether the column contains that word. If the dataframe doesn't contain that word, add "other". See below.
column1_sport column2_type
baseball ball
basketball ball
tennis other
boxing box
golf other