Suppose I have a Pandas series that contains TimeDelta data. In fact, it was generated taking into account the difference in DateTimeIndex with a shifted version of itself, which gives a delta between successive timestamps.
It looks something like
timestamp
2015-02-01 00:00:04 00:00:04
2015-02-01 00:00:08 00:00:04
2015-02-01 00:00:12 00:00:04
....
Name: timestamp, dtype: timedelta64[ns]
The values are obviously numpy.timedelta64, but I need to get them in seconds. The same questions were asked about this, but the answers that I have not yet seen that relate to Pandas 0.16.1.
I tried:
ts.apply(lambda x: x.seconds)
What gives an error
AttributeError: object "numpy.timedelta64" does not have a second attribute
Then tried
numpy.int64(ts)
But that gives me an array. Now I know that I can convert this back to a series, but is there no other way to do this in one Pandas call or match function?