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
Post a Comment