use arrow module
to convert pendulum to datetime
>>> arrow.get(datetime(2013, 5, 5), 'US/Pacific')
<Arrow [2013-05-05T00:00:00-07:00]>
example:
In [90]: import numpy as np
...: import pandas as pd
...: import pendulum
...: import arrow
...:
...: def pendulum_to_datetime(x):
...: return arrow.get(x, x.tz.name).datetime
In [91]: dates = [pendulum.datetime(2011, 1, 2, tz='Asia/Seoul'),
...: pendulum.datetime(2011, 1, 5, tz='Asia/Seoul'),
...: pendulum.datetime(2011, 1, 7, tz='Asia/Seoul')]
In [92]: dates
Out[92]:
[DateTime(2011, 1, 2, 0, 0, 0, tzinfo=Timezone('Asia/Seoul')),
DateTime(2011, 1, 5, 0, 0, 0, tzinfo=Timezone('Asia/Seoul')),
DateTime(2011, 1, 7, 0, 0, 0, tzinfo=Timezone('Asia/Seoul'))]
In [93]: dates2 = [pendulum_to_datetime(x) for x in dates]
In [94]: dates2
Out[94]:
[datetime.datetime(2011, 1, 2, 0, 0, tzinfo=tzfile('ROK')),
datetime.datetime(2011, 1, 5, 0, 0, tzinfo=tzfile('ROK')),
datetime.datetime(2011, 1, 7, 0, 0, tzinfo=tzfile('ROK'))]
In [95]: s1 = pd.Series(np.random.randn(3), index=dates2)
In [96]: s1
Out[96]:
2011-01-02 00:00:00+09:00 -0.359771
2011-01-05 00:00:00+09:00 -0.208608
2011-01-07 00:00:00+09:00 -0.051233
dtype: float64
In [97]: s1.index
Out[97]:
DatetimeIndex(['2011-01-02 00:00:00+09:00', '2011-01-05 00:00:00+09:00',
'2011-01-07 00:00:00+09:00'],
dtype='datetime64[ns, tzfile('ROK')]', freq=None)
In [98]: s2 = pd.Series(dates2)
In [99]: s2
Out[99]:
0 2011-01-02 00:00:00+09:00
1 2011-01-05 00:00:00+09:00
2 2011-01-07 00:00:00+09:00
dtype: datetime64[ns, tzfile('ROK')]