在夏令时转换窗口中工作[Python]

时间:2017-11-30 10:47:25

标签: python pandas datetime dst

chicago = pytz.timezone("America/Chicago")
datetime_date = pytz.utc.localize(datetime(2017,10,30))
date_ranges = pd.date_range(datetime_date, datetime.now()-timedelta(days=1))

[x.astimezone(chicago) + timedelta(hours=6) for x in date_ranges]

[Timestamp('2017-10-30 01:00:00-0500', tz='America/Chicago'),
 Timestamp('2017-10-31 01:00:00-0500', tz='America/Chicago'),
 Timestamp('2017-11-01 01:00:00-0500', tz='America/Chicago'),
 Timestamp('2017-11-02 01:00:00-0500', tz='America/Chicago'),
 Timestamp('2017-11-03 01:00:00-0500', tz='America/Chicago'),
 Timestamp('2017-11-04 01:00:00-0500', tz='America/Chicago'),
 Timestamp('2017-11-05 01:00:00-0500', tz='America/Chicago'),
 Timestamp('2017-11-06 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-07 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-08 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-09 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-10 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-11 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-12 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-13 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-14 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-15 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-16 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-17 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-18 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-19 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-20 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-21 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-22 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-23 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-24 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-25 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-26 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-27 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-28 00:00:00-0600', tz='America/Chicago'),
 Timestamp('2017-11-29 00:00:00-0600', tz='America/Chicago')]

我想创建一个所有小时数= 0的日期范围,但转换前日期的所有小时数显示为1.如何管理此夏令时转换?

0 个答案:

没有答案