maxframe.dataframe.DataFrame.between_time#

DataFrame.between_time(start_time, end_time, inclusive='both', axis=0)#

选择一天中特定时间之间的值(例如,上午9:00-9:30)。

通过将 start_time 设置为晚于 end_time,可以获得 在两个时间之间的时段。

参数:
  • start_time (datetime.time or str) -- 作为时间过滤限制的起始时间。

  • end_time (datetime.time or str) -- 作为时间过滤限制的结束时间。

  • inclusive ({"both", "neither", "left", "right"}, default "both") -- 包含边界;是否将每个边界设置为闭区间或开区间。

  • axis ({0 or 'index', 1 or 'columns'}, default 0) -- 确定在索引或列值上的时间范围。对于 Series,此参数未使用,默认为 0。

返回:

从原始对象中筛选出指定日期范围内的数据。

返回类型:

Series or DataFrame

抛出:

TypeError -- 如果索引不是 DatetimeIndex

参见

at_time

选择一天中特定时间的值。

first

根据日期偏移选择时间序列的初始时间段。

last

根据日期偏移选择时间序列的最终时间段。

DatetimeIndex.indexer_between_time

仅获取一天中特定时间之间值的索引位置。

示例

>>> import maxframe.dataframe as md
>>> i = md.date_range('2018-04-09', periods=4, freq='1D20min')
>>> ts = md.DataFrame({'A': [1, 2, 3, 4]}, index=i)
>>> ts.execute()
                     A
2018-04-09 00:00:00  1
2018-04-10 00:20:00  2
2018-04-11 00:40:00  3
2018-04-12 01:00:00  4
>>> ts.between_time('0:15', '0:45').execute()
                     A
2018-04-10 00:20:00  2
2018-04-11 00:40:00  3

通过将 start_time 设置为晚于 end_time,可以获得 在两个时间之间的时段:

>>> ts.between_time('0:45', '0:15').execute()
                     A
2018-04-09 00:00:00  1
2018-04-12 01:00:00  4