Home > Mobile >  How can I query a column of a dataframe on a specific value and get the values of two other columns
How can I query a column of a dataframe on a specific value and get the values of two other columns

Time:12-13

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.

Using the .query method wasn't effective in returning three columns of the data frame.

Can somebody please suggest another solution?

CodePudding user response:

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')")
  • Related