I see

In[2]: pandas.tslib.Timedelta.total_seconds(pandas.NaT)
Out[2]: -9223372036.854776

Expected Output

Out[2]: nan

Output of pd.show_versions():

INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 42 Stepping 7, GenuineIntel byteorder: little LC_ALL: None LANG: en pandas: 0.18.1 nose: 1.3.7 pip: 8.1.2 setuptools: 25.1.6 Cython: 0.24.1 numpy: 1.11.1 scipy: 0.18.0 statsmodels: 0.8.0rc1 xarray: 0.8.2 IPython: 5.1.0 sphinx: 1.4.6 patsy: 0.4.1 dateutil: 2.5.3 pytz: 2016.6.1 blosc: 1.4.1 bottleneck: 1.1.0 tables: 3.2.3 numexpr: 2.6.1 matplotlib: 1.5.2 openpyxl: 2.4.0 xlrd: 1.0.0 xlwt: None xlsxwriter: 0.9.3 lxml: 3.6.4 bs4: 4.5.1 html5lib: 0.999999999 httplib2: None apiclient: None sqlalchemy: 1.0.14 pymysql: None psycopg2: None jinja2: 2.8 boto: None pandas_datareader: 0.2.1

Comment From: jreback

pls check with 0.19.1

Comment From: jondo

Sorry, I don' have 0.19.1 around yet. Can somebody else please test?

Possible workarounds are pandas.NaT / numpy.timedelta64(1, 's'), or pandas.Series.dt.total_seconds for timedelta series.

Comment From: jorisvandenbossche

It's the same on 0.19.1 / master

@jondo The more canonical way is rather:

In [10]: pd.Timedelta(pd.NaT)
Out[10]: NaT

In [11]: pd.Timedelta(pd.NaT).total_seconds()
Out[11]: nan

(and this one is correct), or indeed if you have a series of such values, by using s.dt.total_seconds()

Comment From: jreback

odd that total_sexonds can take an argument (or even be called as a class method)

Comment From: jorisvandenbossche

Yep, this is like that in the datetime.timedelta class (although I personally don't see the value in using it like that), but I would have expected that we override that method in the pandas Timedelta class

Comment From: jorisvandenbossche

The total_seconds is defined as

class Timedelta(..):

....

    def total_seconds(self):
        """
        Total duration of timedelta in seconds (to ns precision)
        """
        return 1e-9 *self.value

so if you do pd.Timedelta.total_seconds(pd.NaT), it will just check pd.NaT.value, and hence the output. This could be easily solved by checking for NaT in this method. But as it is not really the intended usage (self can in principle never be NaT), I would personally close this as a "won't fix"

Comment From: jondo

I'd also be OK with "won't fix". @jorisvandenbossche, thank you for showing the canonical way.