Filter pandas DataFrame by substring criteria

Question

I have a pandas DataFrame with a column of string values. I need to select rows based on partial string matches.

Something like this idiom:

re.search(pattern, cell_in_question) 

returning a boolean. I am familiar with the syntax of df[df['A'] == "hello world"] but can't seem to find a way to do the same with a partial string match, say 'hello'.

Answer

Vectorized string methods (i.e. Series.str) let you do the following:

df[df['A'].str.contains("hello")]

This is available in pandas 0.8.1 and up.

Change column type in pandas

How to add a new column to an existing DataFrame?