Pandas Compare rows in Dataframe
<p>I have following data frame (represented by dictionary below):</p>

<pre><code>{'Name': {0: '204',
  1: '110838',
  2: '110999',
  3: '110998',
  4: '111155',
  5: '111710',
  6: '111157',
  7: '111156',
  8: '111144',
  9: '118972',
  10: '111289',
  11: '111288',
  12: '111145',
  13: '121131',
  14: '118990',
  15: '110653',
  16: '110693',
  17: '110694',
  18: '111577',
  19: '111702',
  20: '115424',
  21: '115127',
  22: '115178',
  23: '111578',
  24: '115409',
  25: '115468',
  26: '111711',
  27: '115163',
  28: '115149',
  29: '115251'},
 'Sequence_new': {0: 1.0,
  1: 2.0,
  2: 3.0,
  3: 4.0,
  4: 5.0,
  5: 6.0,
  6: 7.0,
  7: 8.0,
  8: 9.0,
  9: 10.0,
  10: 11.0,
  11: 12.0,
  12: nan,
  13: 13.0,
  14: 14.0,
  15: 15.0,
  16: 16.0,
  17: 17.0,
  18: 18.0,
  19: 19.0,
  20: 20.0,
  21: 21.0,
  22: 22.0,
  23: 23.0,
  24: 24.0,
  25: 25.0,
  26: 26.0,
  27: 27.0,
  28: 28.0,
  29: 29.0},
 'Sequence_old': {0: 1,
  1: 2,
  2: 3,
  3: 4,
  4: 5,
  5: 6,
  6: 7,
  7: 8,
  8: 9,
  9: 10,
  10: 11,
  11: 12,
  12: 13,
  13: 14,
  14: 15,
  15: 16,
  16: 17,
  17: 18,
  18: 19,
  19: 20,
  20: 21,
  21: 22,
  22: 23,
  23: 24,
  24: 25,
  25: 26,
  26: 27,
  27: 28,
  28: 29,
  29: 30}}
</code></pre>

<p>I am trying to understand what changed between old and new sequences. If by <code>Name Sequence_old = Sequence_new</code>, nothing changed. If <code>Sequence+_new</code> is <code>'nan'</code>, Name removed. Can you please help implement this in pandas?
What tried till now without success:</p>

<pre><code>for i in range(0, len(Merge)):
    if Merge.iloc[i]['Sequence_x'] == Merge.iloc[i]['Sequence_y']:
        Merge.iloc[i]['New'] = 'N'
    else:
        Merge.iloc[i]['New'] = 'Y'
</code></pre>

<p>Thank you</p>

<pre><code>dic_new = {0: 1.0, 1: 2.0, 2: 3.0, 3: 4.0, 4: 5.0, 5: 6.0, 6: 7.0, 7: 8.0, 8: 9.0, 9: 10.0, 10: 11.0, 11: 12.0,
           12: 'Nan', 13: 13.0, 14: 14.0, 15: 15.0, 16: 16.0, 17: 17.0, 18: 18.0, 19: 19.0, 20: 20.0, 21: 21.0,
           22: 22.0, 23: 23.0, 24: 24.0, 25: 25.0, 26: 26.0, 27: 27.0, 28: 28.0, 29: 29.0}
dic_old = {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7, 7: 8, 8: 9, 9: 10, 10: 11, 11: 12, 12: 13, 13: 14, 14: 15, 15: 16,
           16: 17, 17: 18, 18: 19, 19: 20, 20: 21, 21: 22, 22: 23, 23: 24, 24: 25, 25: 26, 26: 27, 27: 28, 28: 29,
           29: 30}

# Does the same thing as the code below
for a, b in zip(dic_new.items(), dic_old.items()):
    if b[1].lower() != 'nan':
        # You can add whatever print statement you want here
        print(a[1] == b[1])

# Does the same thing as the code above
[print(a[1] == b[1]) for a, b in zip(dic_new.items(), dic_old.items()) if b[1].lower() != 'nan']
</code></pre>

python pandas missing-data