Im trying to find a way to compare what students performed consistantly in their InternalAssessment_Performance to their FinalExam_Performance. Essentially i need to find what students have the same answer in both those columns. How is it possible to compare the values in both commons and have them returned if they are the same? Any help no matter how small would be great.
Asked
Active
Viewed 26 times
-1
-
https://stackoverflow.com/questions/17071871/how-to-select-rows-from-a-dataframe-based-on-column-values – user1558604 Dec 07 '19 at 20:34
-
1Please provide sample data, what you've tried so far, and your expected output. – tim Dec 07 '19 at 20:42
-
1You need to share far more information than this. Please see: [mcve], [ask]. – AMC Dec 07 '19 at 21:01
1 Answers
0
If the columns are aligned you can do something like this:
df[df['InternalAssessment_Performance'] == df['FinalExam_Performance']]

oppressionslayer
- 6,942
- 2
- 7
- 24
-
Yes this works perfect thankyou, lets say i needed to compare it to more columns too. Would i simple just add more '=='? – Jwright164 Dec 07 '19 at 21:41
-
yes, add them with parens: like this: df[(df['InternalAssessment_Performance'] == df['FinalExam_Performance']) & ( df['another'] == df['anotherone'])] – oppressionslayer Dec 07 '19 at 22:10