Given the following df:
data = {'Description': ['with chicken', 'champagne', 'Chicken', 'bananas and chicken', 'fafsa Lemons', 'GIN CHICKEN'],}
df = pd.DataFrame(data)
print (df)
if I search on the column of a word, in this case "chicken", I would like to find the initial position in the string if present, here the expected output:
data = {'Description': ['with chicken', 'champagne', 'chicken', 'bananas and chicken','fafsa Lemons', 'GIN CHICKEN'],
'ChickenPosition': ['6', 'NA', '1', '13', 'NA', '5']
}
df = pd.DataFrame(data)
print (df)
anybody able to write something extremely compact without many steps? Thanks a lot in advance!