J
J
Joseph Goodman2020-07-17 15:33:35
Python
Joseph Goodman, 2020-07-17 15:33:35

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

1 answer(s)
D
Denis Konoplyanikov, 2021-05-03
@DeKon

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 question

Ask a Question

731 491 924 answers to any question