title: Efficient way of conditional value setting
body: <p>I have a pandas DataFrame of operations in my application:</p>
  
  <pre><code>+----------+-------------+
  | UserName |  StartEdit  |
  +----------+-------------+
  | John     | 12-Jul-2015 |
  | David    | 16-Aug-2015 |
  | Katie    | 20-Aug-2015 |
  | Cristin  | 2-Sep-2015  |
  | Katie    | 12-Sep-2015 |
  | John     | 23-Nov-2015 |
  | David    | 2-Jan-2016  |
  | David    | 3-Jan-2016  |
  | John     | 10-Feb-2016 |
  | Steven   | 13-Mar-2016 |
  | Steven   | 14-Mar-2016 |
  +----------+-------------+
  </code></pre>
  
  <p>I would like to create another column with UserTeam. I know that Katie, Cristin and Steven have always been on the same team:</p>
  
  <pre><code>owners_teams = {"Katie":"A", "Cristin":"B", "Steven":"C"}
  </code></pre>
  
  <p>So when I do <code>df["UserTeam"] = df["UserName"].map(owners_teams)</code> I get:</p>
  
  <pre><code>+----------+-------------+----------+
  | UserName |  StartEdit  | UserTeam |
  +----------+-------------+----------+
  | John     | 12-Jul-2015 | NaN      |
  | David    | 16-Aug-2015 | NaN      |
  | Katie    | 20-Aug-2015 | A        |
  | Cristin  | 2-Sep-2015  | B        |
  | Katie    | 12-Sep-2015 | A        |
  | John     | 23-Nov-2015 | NaN      |
  | David    | 2-Jan-2016  | NaN      |
  | David    | 3-Jan-2016  | NaN      |
  | John     | 10-Feb-2016 | NaN      |
  | Steven   | 13-Mar-2016 | C        |
  | Steven   | 14-Mar-2016 | C        |
  +----------+-------------+----------+
  </code></pre>
  
  <p>Now, I also know that:</p>
  
  <p>John moved from <code>A</code> to <code>C</code> on <code>01-Jan-2016</code></p>
  
  <p>David moved from <code>B</code> to <code>C</code> on <code>12-Dec-2015</code></p>
  
  <pre><code>changes = [("John", "01-Jan-2016", "A", "C"), ("David", "12-Dec-2015", "B", "C")]
  </code></pre>
  
  <p>I know how to do it with <code>apply</code> and looping over the rows and hardcoding all rules but I don't think it's efficient. How do I do it in a vectorized way for a big number of users? </p>
  
  <p>Expected result:</p>
  
  <pre><code>+----------+-------------+----------+
  | UserName |  StartEdit  | UserTeam |
  +----------+-------------+----------+
  | John     | 12-Jul-2015 | A        |
  | David    | 16-Aug-2015 | B        |
  | Katie    | 20-Aug-2015 | A        |
  | Cristin  | 2-Sep-2015  | B        |
  | Katie    | 12-Sep-2015 | A        |
  | John     | 23-Nov-2015 | A        |
  | David    | 2-Jan-2016  | C        |
  | David    | 3-Jan-2016  | C        |
  | John     | 10-Feb-2016 | C        |
  | Steven   | 13-Mar-2016 | C        |
  | Steven   | 14-Mar-2016 | C        |
  +----------+-------------+----------+
  </code></pre>