I have a data frame that contains multiple columns that identify if a "Yes" or "No" response based on various conditions. Table_Exmaple
I am trying to create a new column that counts the "Yes" responses across these conditions. New column: Table_with_new_Count_Column
I tried the solution from this other question Efficient way to count string values across multiple columns to create new total column
and variations of it from other posts, but keep getting errors, most commonly:
df2['Count'] = df2.iloc[:, 0:9].eq('Yes').sum(axis=1)
<ipython-input-21-189874c017d3>:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
df2['Count'] = df2.iloc[:, 0:9].eq('Yes').sum(axis=1)
I've looked everywhere and am probably missing something simple. Any help would be greatly appreciated.