Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫市场日历缺少第一期_Python_Datetimeindex - Fatal编程技术网

Python 熊猫市场日历缺少第一期

Python 熊猫市场日历缺少第一期,python,datetimeindex,Python,Datetimeindex,为什么第一节课(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.d

为什么第一节课(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)

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

相关文档串

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

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