I hope I can explain my problem correctly.. I have a dataframe (306x40) with multiple rows containing data of certain group, I need to group them by index, that's no problem. Next I need to compare the rows with another row that has a specific condition. Take this data as an example:
Id Condition var1 var2 var3
1 1 0 1 0
1 3 1 1 0
2 2 0 0 1
2 3 0 0 1
2 1 0 0 1
So I need to compare var1, var2, var3 per Id with the row that has condition 3.. The outcome would let me know that any of the variables is different than the variables in condition 3. Possible outputs:
Id Condition var1 var2 var3 count_false
1 1 false true true 1
1 3 NaN NaN NaN NaN
2 2 true true true 0
2 3 NaN NaN NaN NaN
2 1 true true true 0
Or just simply saying that condition x is not the same as condition 3 for y Id
I hope you guys understand what I need, but I'm happy to elaborate
Thank you so much in advance!
edit to make it more clear:
The data consists of data from 3 different methods to detect bacteria in patients (clinical data), note that per patient it differs which method was used and how many times. So I have method 1, 2, 3, these are the different conditions. The variables are the different kinds of bacteria found. Method 1 and 2 are the golden standard and method 3 is the one that needs to be validated. So I want to see if method 3 gives the same result as method 1 or 2. the 30+ variables are the bacteria and value 1 indicates present bacteria and 0 not present.
NaN?var3can be computed just fromvar1andvar2of that row, i.e. regardless of other rows? Why the groupby then?