本文翻译自:Select by partial string from a pandas DataFrame
I have a DataFrame
with 4 columns of which 2 contain string values. 我有一个带有4列的DataFrame
,其中2列包含字符串值。 I was wondering if there was a way to select rows based on a partial string match against a particular column? 我想知道是否有一种方法可以根据针对特定列的部分字符串匹配来选择行?
In other words, a function or lambda function that would do something like 换句话说,一个函数或lambda函数将执行以下操作
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'
. 我对df[df['A'] == &