I am trying to make two new groups, one with continuous variable y's data where answer X is "Yes", and another where the X is "No". The two lists should contain the two different groups' corresponding Y scores.
I've tried some variations and different code but nothing has let me take the value 'X' to return another in the data frame that keeps the list unique, or runs.
I used this:
for ind in do.index: if re.search('No', do['X'][ind]): dk['opn'] = do['Y']
And it returned the same Y for both 'No' and 'Yes', making identical lists. This occurred when I did them separately or together in the same function.
I also tried:
for col in do.columns: if (do[col].nunique()<=4) & (col not in cols_to_exclude): do[col] = do[col].astype('category')
And it returned:
unsupported operand type(s) for &: 'int' and 'str'
I also tried this:
for c in do['X']: if c == 'Yes': opy.append(do['Y'])
But I got the list repeated MANY times without error or clear reason, within the variable I'd made, repeating the list over and over. Both list logics for no or yes also produced the same list.
The variable contents looked like this but many times over:
Name: Y, Length: 208, dtype: float64, 459 10.0 461 10.0 463 5.0 465 9.0 466 9.0 ... 1075 7.0 1079 9.0 1081 9.0 1084 7.0 1089 8.0 Name: Y, Length: 208, dtype: float64, 459 10.0 461 10.0 463 5.0 465 9.0 466 9.0 ... 1075 7.0 1079 9.0 1081 9.0 1084 7.0 1089 8.0