title: Pandas dataframe frequencies
body: <p>I have this dataframe:</p>
  
  <pre><code>source target
  0     ape    dog
  1     ape   hous
  2     dog   hous
  3    hors    dog
  4    hors    ape
  5     dog    ape
  6     ape   bird
  7     ape   hous
  8    bird   hous
  9    bird   fist
  10   bird    ape
  11   fist    ape
  </code></pre>
  
  <p>I am trying to generate a frequency count with this code:</p>
  
  <pre><code>df_count =df.groupby(['source', 'target']).size().reset_index().sort_values(0, ascending=False)
  df_count.columns = ['source', 'target', 'weight']
  </code></pre>
  
  <p>I get the result below.</p>
  
  <pre><code>source target  weight
  2     ape   hous       2
  0     ape   bird       1
  1     ape    dog       1
  3    bird    ape       1
  4    bird   fist       1
  5    bird   hous       1
  6     dog    ape       1
  7     dog   hous       1
  8    fist    ape       1
  9    hors    ape       1
  10   hors    dog       1
  </code></pre>
  
  <p>How can I modify the code so that direction does not matter, i.e. that instead of <code>ape  bird  1</code> and <code>bird  ape  1</code>, i get <code>ape  bird 2</code>?</p>