title: Transform multiple categorical columns
body: <p>In my dataset I have two categorical columns which I would like to numerate. The two columns both contain countries, some overlap (appear in both columns). I would like to give the same number in column1 and column2 for the same country.</p>
  
  <p>My data looks somewhat like:</p>
  
  <pre><code>import pandas as pd
  
  d = {'col1': ['NL', 'BE', 'FR', 'BE'], 'col2': ['BE', 'NL', 'ES', 'ES']}
  df = pd.DataFrame(data=d)
  df
  </code></pre>
  
  <p>Currenty I am transforming the data like:</p>
  
  <pre><code>from sklearn.preprocessing import LabelEncoder
  df.apply(LabelEncoder().fit_transform)
  </code></pre>
  
  <p>However this makes no distinction between FR and ES. Is there another simple way to come to the following output?</p>
  
  <pre><code>o = {'col1': [2,0,1,0], 'col2': [0,2,4,4]}
  output = pd.DataFrame(data=o)
  output
  </code></pre>