title: Compare one row of a dataframe with the corresponding one and store the data in two separate columns
body: <p>I have a dataframe which looks like this:</p>
  
  <pre><code> Rule ID
  0 51183
  1 50014
  2 53382
  3 51893
  </code></pre>
  
  <p>With this data , I want to create another dataframe which will contain 2 columns, namely <code>X</code> and <code>Y</code>and will hold the comparison of one row with another. The result will look something like this:</p>
  
  <pre><code>  X      Y
  51183  50014
  51183  53382
  51183  51893
  50014  53382
  50014  51893
  53382  51893
  </code></pre>
  
  <p>So, what is happening here is, the first value present in the <code>Rule ID</code> column, i.e, <code>51183</code> is compared with the second value present in the second row, i.e, <code>50014</code>. So <code>51183</code> is stored in <code>X</code> column and <code>50014</code> is stored in <code>Y</code> column. Similarly, <code>51183</code> is then compared with the third row value, i.e, <code>53382</code> , and then with <code>51893</code>. So, after the first row value(<code>51183</code>) is compared with all the rows below it, the comparison will move to the next row, ie, <code>50014</code>, then this value will compare with <code>53382</code> and <code>51893</code> respectively and so on.</p>
  
  <p>I tried this code, where I tried <code>stack()</code> method but it seems wrong:</p>
  
  <pre><code>df1 = df.stack()
  df1.columns = ['X', 'Y']
  </code></pre>
  
  <p>Here <code>df</code> is the dataframe which stores the <code>Rule ID</code> data.</p>
  
  <p>If you guys colud help me, I would greatly appreciate it.</p>