)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.between_time  #

DataFrame.  between_time  (  _ start_time  _ , _ end_time  _ , _ inclusive  =
'both'  _ , _ axis  =  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L9297-L9380) #

    

Select values between particular times of the day (e.g., 9:00-9:30 AM).

By setting ` start_time  ` to be later than ` end_time  ` , you can get the
times that are _not_ between the two times.

Parameters  :

    

**start_time** datetime.time or str

    

Initial time as a time filter limit.

**end_time** datetime.time or str

    

End time as a time filter limit.

**inclusive** {âbothâ, âneitherâ, âleftâ, ârightâ}, default
âbothâ

    

Include boundaries; whether to set each bound as closed or open.

**axis** {0 or âindexâ, 1 or âcolumnsâ}, default 0

    

Determine range time on index or columns value. For  Series  this parameter is
unused and defaults to 0.

Returns  :

    

Series or DataFrame

    

Data from the original object filtered to the specified dates range.

Raises  :

    

TypeError

    

If the index is not a [ ` DatetimeIndex  `
](pandas.DatetimeIndex.html#pandas.DatetimeIndex "pandas.DatetimeIndex")

See also

[ ` at_time  ` ](pandas.DataFrame.at_time.html#pandas.DataFrame.at_time
"pandas.DataFrame.at_time")

    

Select values at a particular time of the day.

[ ` first  ` ](pandas.DataFrame.first.html#pandas.DataFrame.first
"pandas.DataFrame.first")

    

Select initial periods of time series based on a date offset.

[ ` last  ` ](pandas.DataFrame.last.html#pandas.DataFrame.last
"pandas.DataFrame.last")

    

Select final periods of time series based on a date offset.

[ ` DatetimeIndex.indexer_between_time  `
](pandas.DatetimeIndex.indexer_between_time.html#pandas.DatetimeIndex.indexer_between_time
"pandas.DatetimeIndex.indexer_between_time")

    

Get just the index locations for values between particular times of the day.

Examples

    
    
    >>> i = pd.date_range('2018-04-09', periods=4, freq='1D20min')
    >>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
    >>> ts
                         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')
                         A
    2018-04-10 00:20:00  2
    2018-04-11 00:40:00  3
    

You get the times that are _not_ between two times by setting ` start_time  `
later than ` end_time  ` :

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

[ __ previous  pandas.DataFrame.at_time  ](pandas.DataFrame.at_time.html
"previous page") [ next  pandas.DataFrame.drop  __
](pandas.DataFrame.drop.html "next page")

__ On this page

  * ` DataFrame.between_time()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.between_time.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.