I'm trying to search in string in dataframe column by using contains
1.
for idx, row in df.iterrows():
if(row['name'].str.contains('abc')):
the above code throw this error
AttributeError: 'str' object has no attribute 'str'
2.
for idx, row in df.iterrows():
if(row['name'].contains('abc')):
and the second code throw this error
AttributeError: 'str' object has no attribute 'contains'
rowshould have thestrattribute, but the computer says it does not. Before asking on SO, dodir(row)orprint(type(row))orprint(row)to find out what you're getting. This is going to be very common in your programming career, and the sooner your instincts change from "Ask the world for the answer" to "Check and see if maybe I'm a clumsy meatbag for the 100th time this week, first," the faster you'll become a better programmer. meta.stackoverflow.com/questions/261592/…