How to compare two columns of the same dataframe?

后端 未结 3 571
無奈伤痛
無奈伤痛 2021-01-05 07:22

I have a dataframe like this:

 match_id inn1  bat  bowl  runs1 inn2   runs2   is_score_chased
    1     1     KKR  RCB    222  2      82          1
    2             


        
3条回答
  •  盖世英雄少女心
    2021-01-05 07:45

    You need to reference the fact that you are iterating through the dataframe, so;

    for i in (high_scores1):
      if(high_scores1['runs1'][i]>=high_scores1['runs2'][i]):
          high_scores1['is_score_chased'][i]='yes'
      else:
          high_scores1['is_score_chased'][i]='no' 
    

提交回复
热议问题