title: Pandas Assign Lambda Function
body: <p>I have a DataFrame which has an open time and a close time and I am trying to calculate the difference in milliseconds.</p>
  
  <p>My code is currently like this</p>
  
  <pre><code>df = df.assign(Latency=lambda d: d.CloseTimeStamp - d.CreationTimeStamp)
  df.Latency = df.apply(lambda d: d.Latency.total_seconds() * 1000., axis=1)
  </code></pre>
  
  <p>However, I'd like to know why I can't do as a one-liner like so</p>
  
  <pre><code>df = df.assign(Latency=lambda d: (d.CloseTimeStamp - d.CreationTimeStamp).total_seconds() * 1000.)
  </code></pre>
  
  <p>When I try the latter I get <code>AttributeError: 'Series' object has no attribute 'total_seconds'</code></p>