Answer the question
In order to leave comments, you need to log in
How to display data containing a substring in Pandas?
Good afternoon.
Let's say we have a df dataframe with columns First, Second, Third, which contain textual information.
How can I display only those lines that contain any substring:
1) Considering all 3 columns at once?
2) Considering only one specific column?
Answer the question
In order to leave comments, you need to log in
You need to specify the columns in which you are looking for data through the loc / iloc methods and specify the search strings through the comparison operator.
To specify only certain columns, you must specify them in square brackets in the list format
df.loc[df['First'] == 'some']
df.loc[df['First'] == 'some']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question