0

I know that it's possible to convert a single datetime observation to Unix timestamp by:

import datetime as dt
int(dt.datetime.now().timestamp())

How could I do this conversion with a Series like this:

import pandas as pd
x = dt.datetime.now()
y = x + dt.timedelta(seconds=300)
z = pd.Series([x, y])

z:

0   2019-03-22 13:53:42.671575
1   2019-03-22 13:58:42.671575
dtype: datetime64[ns]
José Vallejo
  • 356
  • 4
  • 17

1 Answers1

0
z = pd.Series([int(x.timestamp()), int(y.timestamp())])

z

0    1553259897
1    1553260197
dtype: int64

.

z = []
for i,s in enumerate(array):
    z[i] = pd.Series([int(s[0].timestamp()), int(s[1].timestamp())])
Manuel
  • 117
  • 2
  • 9