title: Python: Replacement not allowed with overlapping keys and values
body: <p>I'm trying to shuffle the values from an input dataframe, store these new values into a dictionary, and then get an output dataframe by replacing the input dataframe values with their dictionary mapping.</p>
  
  <p>However, I get the "Replacement not allowed with overlapping keys and values" error.</p>
  
  <p>Here's my code sample:</p>
  
  <pre><code>in_df = ['A','B','C']
  in_df = pd.DataFrame(in_df,columns=['Alphabets'])
  df_temp = in_df.sample(frac=1).reset_index(drop=True)
  df_temp = df_temp.rename(columns={'Alphabets':'sample'})
  mask_dict = dict(zip(in_df['Alphabets'], df_temp['sample']))
  out_df= in_df.replace({'Alphabets': mask_dict})
  </code></pre>
  
  <p>in_df looks as follows:</p>
  
  <pre><code>Alphabets
  A
  B
  C
  </code></pre>
  
  <p>mask_dict looks something like this:</p>
  
  <pre><code>{'A': 'C', 'B': 'A', 'C': 'C'}
  </code></pre>
  
  <p>I want the out_df to look like this:</p>
  
  <pre><code>Alphabets
  C
  A
  C
  </code></pre>
  
  <p><strong>I found a way to do this!</strong></p>
  
  <pre><code>df_temp = in_df.stack().unique()
  df_temp = pd.DataFrame(df_temp, columns=['Alphabets'])
  df_temp1 = df_temp.sample(n=df_temp.size, random_state=123)
  mask_dict = dict(zip(df_temp['Alphabets'], df_temp1['Alphabets']))
  out_df = in_df.applymap(mask_dict.get)
  </code></pre>