title: Convert timedelta64[ns] column to seconds in Python Pandas DataFrame
body: <p>A pandas DataFrame column <code>duration</code> contains <code>timedelta64[ns]</code> as shown. How can you convert them to seconds?</p>
  
  <pre><code>0   00:20:32
  1   00:23:10
  2   00:24:55
  3   00:13:17
  4   00:18:52
  Name: duration, dtype: timedelta64[ns]
  </code></pre>
  
  <p>I tried the following</p>
  
  <pre><code>print df[:5]['duration'] / np.timedelta64(1, 's')
  </code></pre>
  
  <p>but got the error</p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 16, in &lt;module&gt;
      print df[0:5]['duration'] / np.timedelta64(1, 's')
    File "C:\Python27\lib\site-packages\pandas\core\series.py", line 130, in wrapper
      "addition and subtraction, but the operator [%s] was passed" % name)
  TypeError: can only operate on a timedeltas for addition and subtraction, but the operator [__div__] was passed
  </code></pre>
  
  <p>Also tried</p>
  
  <pre><code>print df[:5]['duration'].astype('timedelta64[s]')
  </code></pre>
  
  <p>but received the error</p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 17, in &lt;module&gt;
      print df[:5]['duration'].astype('timedelta64[s]')
    File "C:\Python27\lib\site-packages\pandas\core\series.py", line 934, in astype
      values = com._astype_nansafe(self.values, dtype)
    File "C:\Python27\lib\site-packages\pandas\core\common.py", line 1653, in _astype_nansafe
      raise TypeError("cannot astype a timedelta from [%s] to [%s]" % (arr.dtype,dtype))
  TypeError: cannot astype a timedelta from [timedelta64[ns]] to [timedelta64[s]]
  </code></pre>