Julieta M.
Julieta M.

Reputation: 83

How can I query a column of a dataframe on a specific value and get the values of two other columns corresponding to that value

I have a data frame where the first column contains various countries' ISO codes, while the other 2 columns contain dataset numbers and Linkedin profile links.

Please refer to the image.

I need to query the data frame's first "FBC" column on the "IND" value and get the corresponding values of the "no" and "Linkedin" columns.

Can somebody please suggest a solution?

Upvotes: 1

Views: 67

Answers (1)

Jason Baker
Jason Baker

Reputation: 3706

Using query(): If you want just the no and Linkedin values.

df = df.query("FBC.eq('IND')")[["no", "Linkedin"]]

If you want all 3:

df = df.query("FBC.eq('IND')")

Upvotes: 1

Related Questions