mardi 8 août 2017

Add values into DataFrame Python 3.0

[I'm trying to add values into the 'Overall' column using both if-else and for-loop, however it doesn't seem to work.

I'm using the values from the 'Total' Column of my DataFrame to determine the 'Overall'column value either a Pass or a Fail.]

    for index, row in Score.iterrows():
         if Score['Total']>=100:
            Score.insert(index,'Total', 'Pass')
          else:
            Score.insert(index,'Total', 'Fail')

Name    Maths   English Total   Overall

0 Tom 50 50 100 1 Jack 80 50 130 2 Tim 70 80 150 3 Hen 1 84 85

Attached picture of the problem

Aucun commentaire:

Enregistrer un commentaire