title: Clean a pandas Series: for each row, if string is in values (values=list or set) of dictionary, replace with key
body: <p>I have a book that I have broken down into dialogue for each character, however I noticed there are many typos and different names for the same characters. I created a dictionary hoping to associate each alias back to the proper character, but I am having trouble executing. Here is my Pandas Series and desired output:</p>
  
  <pre><code>Narrator ---&gt; Output
  
  Robert -----&gt; Robert
  Dan    -----&gt; Dan
  Daniel -----&gt; Daniel
  Robbie -----&gt; Robert
  Rob    -----&gt; Robert
  Jacob  -----&gt; Jacob
  </code></pre>
  
  <p>And my dictionary is as follows:</p>
  
  <pre><code>char_dict = {'Robert': ['Robert', 'Robbie', 'Rob'],
               'Daniel': ['Daniel', 'Dan']}
  </code></pre>
  
  <ol>
  <li>If the string is in a list of values in the dictionary, how would I replace it with the key. Do I need to reverse my dictionary?</li>
  <li><p>Can I do this same operation with a set instead of the list in my dictionary?</p>
  
  <p>char_dict = {'Robert': {'Robert', 'Robbie', 'Rob'},
               'Daniel': {'Daniel', 'Dan'}}</p></li>
  </ol>
  
  <p>I have used this code, which actually does get me a working output, but it is very difficult to quickly look at and understand which names are associated with which character. Is there a more efficient method?</p>
  
  <pre><code>new_char_dict = {k: oldk for oldk, oldv in char_dict.items() for k in oldv}
  </code></pre>