Обычные проверки, которые я могу выполнить, используя
m1 = (df[some_column] == some_value )
m2 = ( df[some_column].isin(some_list_of_values) )# This check whether the value of the column is one of the values in the list
m3 = ( df[some_column].str.contains() # You can use it the same as str.contains())
m4 = (df[some_column].str.isdigit()) # Same usage as str.isdigit(), check whether string is all digits, need to make sure column type is string in advance
Затем, чтобы получить фрейм данных после всех вышеупомянутых проверок -
df = df[m1 & m2 & m3 & m4]
Когда я печатаю (df[some_column] == some_value )
, я получаю
0 False
1 True
2 True
Я хочу проверить что-то в функции, используя если еще, как, например,
if min_group_price is True , then both single_male single_female needs to be True
If min_group_price is False , then no check(Final result should be True)
Мои данные испытаний что-то вроде,
min_group_price single_male single_female
0 1.0 2.0 3.0
1 NaN NaN NaN
2 1.0 2.0 NaN
3 NaN 2.0 NaN
4 0.0 NaN 4.0
5 NaN NaN 2.0
В этом согласновышеуказанная логика index 0,1,3,5
должна быть True.Я не хочу к этому.Как я могу это сделать?