简体   繁体   中英

Get column index that matches list values

I am trying to get the column numbers/indexes from a dataframe row that matches the values on a list. I have this:

pos=local.loc[[row_to_verify]].isin(global.index[global['cond'] == 'F'].tolist())

From this part:

global.index[global['cond'] == 'F'].tolist()

I get the list=[1,3] . I want to use these values to select which columns of local[row_to_verify] matches the values from obtained list.

Can you add more specific example? The best will be to see your df and thee output which you want to have. Firstly I thought you want to get index of exact value in specified column, but now I see that you want column number, but I can't see this and example would be helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM