0

I think that I'm cleaning my Data in a poor way. What I need to do is return only a column of a conditional selection of my dataset.

As example:

Heading 1 Heading 2
12 34
99 42

I want to return Heading 2 for every Heading 1 that follow a condition.

What I'm doing is creating a temporary DataFrame:

df = df[df['Heading 1'] > 50]

Then I can get what I want just doing:

df['Heading 2']

But I can probably do it directly. I've tried something like

df['Heading 2'].where(df['Heading 1'] > 50])

But I dont think that that's the way - or maybe I've done something wrong.

0 Answers0