title: How to count unique records by two columns in pandas?
body: <p>I have dataframe in pandas:</p>
  
  <pre><code>In [10]: df
  Out[10]:
      col_a    col_b  col_c  col_d
  0  France    Paris      3      4
  1      UK    Londo      4      5
  2      US  Chicago      5      6
  3      UK  Bristol      3      3
  4      US    Paris      8      9
  5      US   London     44      4
  6      US  Chicago     12      4
  </code></pre>
  
  <p>I need to count unique cities. I can count unique states</p>
  
  <pre><code>In [11]: df['col_a'].nunique()
  Out[11]: 3
  </code></pre>
  
  <p>and I can try to count unique cities</p>
  
  <pre><code>In [12]: df['col_b'].nunique()
  Out[12]: 5
  </code></pre>
  
  <p>but it is wrong because US Paris and Paris in France are different cities. So now I'm doing in like this:</p>
  
  <pre><code>In [13]: df['col_a_b'] = df['col_a'] + ' - ' + df['col_b']
  
  In [14]: df
  Out[14]:
      col_a    col_b  col_c  col_d         col_a_b
  0  France    Paris      3      4  France - Paris
  1      UK    Londo      4      5      UK - Londo
  2      US  Chicago      5      6    US - Chicago
  3      UK  Bristol      3      3    UK - Bristol
  4      US    Paris      8      9      US - Paris
  5      US   London     44      4     US - London
  6      US  Chicago     12      4    US - Chicago
  
  In [15]: df['col_a_b'].nunique()
  Out[15]: 6
  </code></pre>
  
  <p>Maybe there is a better way? Without creating an additional column.</p>