I am trying to determine the number of instances in my dataframe that are both 'Pentioners' and have 'Days employed' = 365243. I can obtain the count of either 'Pensioners' or 'Days employed' seperately, but not the combined requirement.
This function works correctly:
number_pensioners = app_train.apply(lambda x: True if x['NAME_INCOME_TYPE'] == 'Pensioner' else False, axis = 1
)
numRows = len(number_pensioners[number_pensioners == True].index)
However this function returns and error:
number_pensioners = app_train.apply(lambda x: True if x['NAME_INCOME_TYPE'] == 'Pensioner' & x['DAYS_EMPLOYED'] == 365243 else False, axis = 1
)
numRows = len(number_pensioners[number_pensioners == True].index)
The error returned is:
TypeError: ("unsupported operand type(s) for &: 'str' and 'int'", 'occurred at index 0')