Reputation: 305
I have a numpy array with 4 columns. The first column is text.
I want to retrieve every row in the array where the first column contains a substring.
Example: if the string I'm searching for is "table", find and return all rows in the numpy array whose first column contains "table."
I've tried the following:
rows = nparray[searchString in nparray[:,0]]
but that doesn't seem to work
Upvotes: 0
Views: 3280
Reputation: 24181
Given a pandas DataFrame df
, this will return all rows where searchString
is a substring of the value in the column column
:
searchString = "table"
df.loc[df['column'].str.contains(searchString, regex=False)]
Upvotes: 2