
366
11
章 時系列データ
In [110]: import pytz
In [111]: pytz.common_timezones[-5:]
Out[111]: ['US/Eastern', 'US/Hawaii', 'US/Mountain', 'US/Pacific', 'UTC']
pytz.timezone
を使って、
pytz
からタイムゾーンオブジェクトを取得します。
In [112]: tz = pytz.timezone('America/New_York')
In [113]: tz
Out[113]: <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD>
pandas
のメソッドでは、タイムゾーン名やタイムゾーンオブジェクトが利用可能です。
11.4.1
タイムゾーンのローカライゼーションと変換
デフォルトでは、
pandas
の時系列はタイムゾーンに関して曖昧な状態です。次の時系列の例を見て
みましょう。
In [114]: rng = pd.date_range('3/9/2012 9:30', periods=6, freq='D')
In [115]: ts = pd.Series(np.random.randn(len(rng)), index=rng)
In [116]: ts
Out[116]:
2012-03-09 09:30:00 -0.202469
2012-03-10 09:30:00 0.050718
2012-03-11 ...