I have a data frame with String values in one of its columns. I want to iterate each row in the specified column to see if the value contains the word i'm looking for. If it does i want it to return int value 1 and if it doesn't then 0.
df['2'] = df['Col2'].str.lower().str.contains('word')
I can only get it to return True or False
Col1 Col2
1 hello how are you 0
2 that is a big word 1
3 this word is bad 1
4 tonight tonight 0
Aucun commentaire:
Enregistrer un commentaire