python - Extract value from dataframe as float/int in pandas -


i trying extract value of 1 column based on other 2 columns dataframe in python. returns sequence object.

df['a'].where((df['b'] == val1) & (df['c'] == val2)) 

how can extract value of column in int/float or how can convert sequence object int or float?

you can use slicing of column, using mask this:

df['a'][(df['b'] == val1) & (df['c'] == val2)] 

but if want ot modify inplace values of corresponding slice, should try using loc operator:

df.loc[(df['b'] == val1) & (df['c'] == val2),'a'] 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -