If you’d like to learn more about pandas, then check out:
Use Regular Expressions With pandas
The company with ID 656 in your DataFrame has the word
"secretly" in their slogan, and it also shows up. So one useful thing about this
.str.contains() method in pandas is that you can pass a regular expressions match pattern as an argument to
you could put a regular expression in here and say
"secret", and then you want a word character (
\w) and plus quantifier (
+) so that it’s more than one. And if you press Enter here, you can see that the filter returns only the one single row that actually contains the word
"secretly" in that case. Now this, because it’s a regular expression pattern, this could also match another word.
.str.contains() in pandas is an effective and quick way that you can filter your DataFrame for only those rows that contain a certain substring in the values of the series that you’re checking on. And also keep in mind that it allows regular expressions, which makes the search even more powerful.
02:11 If you’re want to get more familiar with pandas, then it’s a good idea to go check these out. That’s it for this course. In the next lesson, we’re going to do a quick recap of everything that you’ve learned.
Become a Member to join the conversation.