0

screenshot of the dataframe table

I want to have another column name final grade that will get the average grade and checks if the average grade is greater than > or equal = to 75. And if so put 'Passed' and if not put 'FAILED'

df_exams['Final Grade'] = 'PASSED' if df_exams.loc[(df_exams['Average Grade'] >= 75)] else 'FAIL'

Can someone help me I am a newbie and want to be a Data Analyst. Thanks in advance

Jj Encrypt
  • 11
  • 5
  • Please replace the images with formatted code/text in the question. See also: [ask] and [How to format code?](https://meta.stackoverflow.com/q/251361/967621) – Timur Shtatland Jun 17 '22 at 15:11

1 Answers1

0

You need to use apply with a lambda function. The example below is from geeksforgeeks. Hope it helps!

df['Result'] = df['Maths'].apply(lambda x: 'Pass' if x>=5 else 'Fail')

ggsmith
  • 31
  • 7