title: Can I use pandas replace function to replace different values in multiple columns with unique values?
body: <p>I have the following simple problem, imagine I have the following dataframe:</p>
  
  <pre><code>df = pd.DataFrame({'A': ['foo', 1, 2, 3, 4],
                     'B': [5, 'dude', 7, 8, 9],
                     'C': ['5', '5', 'dude', '5', '5']})
  print(df)
  
       A     B     C
  0  foo     5     5
  1    1  dude     5
  2    2     7  dude
  3    3     8     5
  4    4     9     5
  </code></pre>
  
  <p>Now I want to replace values <code>['foo','dude','dude']</code>in columns A, B, and C, respectively all with their own unique values. I was able to accomplish this using pandas <code>replace</code> function.</p>
  
  <pre><code>df['A'] = df['A'].replace('foo', value = 68 ).astype(float)
  df['B'] = df['B'].replace('dude', value = 46).astype(float)
  df['C'] = df['C'].replace('dude', value = 86).astype(float)
  </code></pre>
  
  <p>This works, but I know that previously in a lot of code I have written there has been a much simpler, and effective way to accomplish similar problems.  I have an intuitive feeling that there is a better way to accomplish this, however I am unsure what it may be.</p>
  
  <p>Here is what I tried.</p>
  
  <pre><code>dict1={'A':{'foo':68},'B':{'dude': 46}, 'C':{'dude':86}}
  dfclean = df.replace(dict1)
  </code></pre>
  
  <p>but to no avail.  Is it the most efficient way to replace these each with their own line?</p>
  
  <p>EDIT:</p>
  
  <p>Wow, I am a complete moron... The solution I wrote above actually works, I was just printing df, rather than dfclean.  Thanks.</p>