October 2019
Beginner to intermediate
674 pages
16h 43m
English
The contains() method returns checks for the presence of a substring or pattern in all the elements of the series and returns a series of Booleans:
sample_df["Movie"].str.contains("atr")
The following is the output:

Since Matrix is the only movie that contains the atr substring, True is returned at index 2. The substring can also be a regex pattern. To use a regex pattern for string matching, the regex parameter should be set to True. For example, let's identify a string that contains either atr or der:
sample_df["Movie"].str.contains("atr|der", regex = True)
The following ...
Read now
Unlock full access