Pandas市场日历缺少第一期

2024-09-22 14:31:49 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么第一节课(9:30)被取消了

它将第一个周期返回为10:00。这是不正确的

我做错了什么

import pandas_market_calendars as mcal

nyse = mcal.get_calendar('NYSE')
early = nyse.schedule(start_date="2020-07-02", end_date="2020-10-14")  # .strftime(date_fmt)


dates = mcal.date_range(early, frequency="30min")
dates = dates.tz_convert('US/Eastern')
dates

DatetimeIndex(['2020-07-02 10:00:00-04:00', '2020-07-02 10:30:00-04:00',
               '2020-07-02 11:00:00-04:00', '2020-07-02 11:30:00-04:00',
               '2020-07-02 12:00:00-04:00', '2020-07-02 12:30:00-04:00',
               '2020-07-02 13:00:00-04:00', '2020-07-02 13:30:00-04:00',
               '2020-07-02 14:00:00-04:00', '2020-07-02 14:30:00-04:00',
               ...
               '2020-10-14 11:30:00-04:00', '2020-10-14 12:00:00-04:00',
               '2020-10-14 12:30:00-04:00', '2020-10-14 13:00:00-04:00',
               '2020-10-14 13:30:00-04:00', '2020-10-14 14:00:00-04:00',
               '2020-10-14 14:30:00-04:00', '2020-10-14 15:00:00-04:00',
               '2020-10-14 15:30:00-04:00', '2020-10-14 16:00:00-04:00'],
              dtype='datetime64[ns, US/Eastern]', length=949, freq=None)

Tags: importpandasgetdateasmarketcalendarscalendar
1条回答
网友
1楼 · 发布于 2024-09-22 14:31:49

添加参数“closed”,将默认值从“right”更改为“closed”

相关文档串

:param closed:与“日期范围”的含义相同“right”将排除第一个值,并应在 结果应仅包括每个条形图的结束

dates = mcal.date_range(early, frequency="30min", closed = "left")

相关问题 更多 >