title: Pandas calculated column to accrue information
body: <p>I have a data frame like so  which records the type of an IP at a specific time.</p>
  <pre><code>IP   Time                 Type
  101  2018-10-16 01:07:11  A
  101  2018-10-16 01:08:34  A
  101  2018-10-16 02:54:11  B
  101  2018-10-16 14:07:39  A
  
  </code></pre>
  <p>How can I create a new column <code>NumSwitches</code> which keeps track of the number of times the type switches like so in pandas?</p>
  <pre><code>IP   Time                 Type  NumSwitches
  101  2018-10-16 01:07:11  A     0
  101  2018-10-16 01:08:34  A     0
  101  2018-10-16 02:54:11  B     1
  101  2018-10-16 14:07:39  A     2
  
  </code></pre>