I want to add Case=False to the code below so the NON_COV_RFV would flag both 'Seizure' and 'seizure' but am getting an error. Is it possible to add a case=False? I know this can be done in str.contains but there are data in my REASON_FOR_VISIT field, for example seizure, fever, and I would not want to flag that as NON_COV_RFV.
I want to avoid having to write another line of code for "seizure". If it were for just this occurrence it would be fine to add a second line but I have many variables for REASON_FOR_VISIT and that is why I would like to figure out if I can plug in a case=False expression.
COV_RFV.loc[COV_RFV['REASON_FOR_VISIT'] == 'Seizure', case=False, 'NON_COV_RFV'] = 1
ERROR:
COV_RFV.loc[COV_RFV['REASON_FOR_VISIT'] == 'Seizure', case=False, 'NON_COV_RFV'] = 1
^
SyntaxError: invalid syntax
CodePudding user response:
This is not possible, but you could use this workaround:
COV_RFV.loc[COV_RFV['REASON_FOR_VISIT'].str.lower() == 'seizure', 'NON_COV_RFV'] = 1
or
COV_RFV.loc[COV_RFV['REASON_FOR_VISIT'].str.match('Seizure', case=False), 'NON_COV_RFV'] = 1
