So long as dt is a datetime dtype already you can filter using date strings, if not then you can convert doing this:

df['dt'] = pd.to_datetime(df['dt'])

Then filter:

In [115]:

df[(df['dt'] > '2014-07-23 07:30:00') & (df['dt'] < '2014-07-23 09:00:00')]
Out[115]:
                       dt  value
index                           
91    2014-07-23 07:35:00  0.300
92    2014-07-23 07:40:00  0.300
93    2014-07-23 07:45:00  0.216
94    2014-07-23 07:50:00  0.204
95    2014-07-23 07:55:00  0.228
96    2014-07-23 08:00:00  0.228
97    2014-07-23 08:05:00  0.228
98    2014-07-23 08:10:00  0.228
99    2014-07-23 08:15:00  0.240
100   2014-07-23 08:20:00  0.228
101   2014-07-23 08:25:00  0.216
102   2014-07-23 08:30:00  0.228
103   2014-07-23 08:35:00  0.324
104   2014-07-23 08:40:00  0.336
105   2014-07-23 08:45:00  0.324
106   2014-07-23 08:50:00  0.324
107   2014-07-23 08:55:00  0.324
Answer from EdChum on Stack Overflow
🌐
Saturn Cloud
saturncloud.io › blog › how-to-filter-pandas-dataframe-by-time
How to Filter Pandas Dataframe by Time | Saturn Cloud Blog
May 1, 2026 - ... Timestamp is a data type that represents a point in time. In Pandas, timestamp data can be stored in a column as a timestamp object, which can then be used to filter the dataframe.
Discussions

python - How to filter a Pandas dataframe by timestamp functon using .query() - Stack Overflow
I am trying to filter a Pandas df by dates (today and yesterday). For automation purposes I wish to filter using a timestamp function. This is pretty seamless in R: df %>% filter(date >= ... More on stackoverflow.com
🌐 stackoverflow.com
Python Pandas DataFrame: filter by a Timestamp column with a list of string timestamps - Stack Overflow
Although the index is a pd.Timestamp type, I can use a string representation of a timestamp to filter it. For example: df.loc['2008-11-05'] | ts | val 2008-11-05 07:45:23.100 | 2008-11-05 07:45:23.100 | 0 · Moreover, pandas comes with a very convenient feature that when my filter is vague ... More on stackoverflow.com
🌐 stackoverflow.com
September 10, 2019
python - Filtering Pandas DataFrames on dates - Stack Overflow
I have a Pandas DataFrame with a 'date' column. Now I need to filter out all rows in the DataFrame that have dates outside of the next two months. Essentially, I only need to retain the rows that are More on stackoverflow.com
🌐 stackoverflow.com
February 4, 2016
Can you filter pandas dataframes by Day/Month date without year? Writing a generalised function for between date that is year agnostic is proving difficult.
Ths issue stems from using year agnostic dates. If I want to return dates between June 15th - Sep 15th for every year it seems I need to manually… More on reddit.com
🌐 r/learnpython
8
6
April 19, 2024
🌐
IncludeHelp
includehelp.com › python › filter-select-rows-of-pandas-dataframe-by-timestamp-column.aspx
Python - Filter/Select rows of pandas dataframe by timestamp column
September 19, 2023 - We need to find an easy way to create a new data frame from the original data frame that contains rows between the two timestamp values, it means we are required to filter the rows of the original data frame in a specific range of dates. For this purpose, we will first convert the timestamp column into DateTime and then we will apply a condition in which we will define a specific range within which we will extract all the values. ... # Importing pandas package import pandas as pd # Importing numpy package import numpy as np # Creating a dictionary d = { 'dt':['7/23/2014','4/13/2014','8/30/2014
🌐
Towards AI
pub.towardsai.net › how-to-filter-pandas-dataframe-by-time-81509d3adee9
How to Filter Pandas DataFrame by Time | Towards AI
April 28, 2022 - We create two DataFrames, df_row ...00,size=(5, 10)), columns = ts) ... .between_time() is a Pandas DataFrame method that filters for rows in a Pandas DataFrame between a start and end time....
🌐
pythontutorials
pythontutorials.net › blog › filter-select-rows-of-pandas-dataframe-by-timestamp-column
How to Filter Pandas DataFrame Rows by Timestamp: Easy Way to Select Between Two Datetimes (Beginner’s Guide)
Filtered DataFrame (Method 1 - Boolean Indexing): timestamp temperature 1 2023-01-02 12:30:00 23.1 2 2023-01-03 15:45:00 21.8 3 2023-01-05 09:15:00 24.0 4 2023-01-07 14:20:00 22.9 · Note: Use & (not and) to combine conditions, and wrap each condition in parentheses (). Pandas Series has a built-in between() method that checks if values lie within a range.
🌐
YouTube
youtube.com › watch
Filter Your DataFrame by Timestamp: A Simple Guide for Python Pandas - YouTube
Learn how to filter a Pandas DataFrame using a timestamp column to only retain rows matching a specific time, with step-by-step solutions.---This video is ba...
Published: April 16, 2025
Views: 0
🌐
Finxter
blog.finxter.com › 5-best-ways-to-filter-a-pandas-dataframe-by-time
5 Best Ways to Filter a Pandas DataFrame by Time – Be on the Right Side of Change
March 4, 2024 - import pandas as pd # Create a ... how to create a DataFrame using pandas with hourly timestamps and then apply between_time() to filter records that fall between 9 AM and 5 PM of the given day....
Find elsewhere
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas filter dataframe rows on dates
Pandas Filter DataFrame Rows on Dates - Spark By {Examples}
October 4, 2024 - Pandas Filter DataFrame Rows by matching datetime (date) - To filter/select DataFrame rows by conditionally checking date use DataFrame.loc[] and
🌐
Kanoki
kanoki.org › 2022 › 07 › 16 › pandas-filter-dates-by-month-hour-day-or-last-n-days-weeks
Pandas filter dates by month, hour, day and last N days & weeks | kanoki
July 16, 2022 - We have dataframe with dates or timestamps columns and we would like to filter the rows by Month, Hour, day or by last n days from today’s date. Pandas has a dt accessor object for datetimelike properties of the series and can be used to access the properties from Timestamp or a collection ...
🌐
GPT Tutor Pro
gpttutorpro.com › pandas-dataframe-filtering-using-datetime-methods
Pandas DataFrame Filtering: Using Datetime Methods
March 12, 2024 - In this tutorial, you will learn how to use datetime methods in Pandas to filter data based on dates and times. Datetime methods are special functions that allow you to work with date and time data in Pandas. You will learn how to create a datetime index, filter data by date, time, date range, time range, day of week, month, or year in Pandas.
🌐
DataScientYst
datascientyst.com › filter-by-date-pandas-dataframe
How to Filter DataFrame by Date in Pandas
December 2, 2021 - Here are several approaches to filter rows in Pandas DataFrame by date: 1) Filter rows between two dates df[(df['date'] > '2019-12-01'
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-filter-dataframe-rows-based-on-the-date-in-pandas
How to Filter DataFrame Rows Based on the Date in Pandas? - GeeksforGeeks
December 4, 2023 - 4 min read How to Sort a Pandas DataFrame by Date? In the real world, we can come across datasets of any form that may include the date inside them too. These datasets can be present in any file format like .CSV, .xlsx, .txt, etc. To load this data inside Python, we use a library named Pandas which provides us a plethora of functions and methods to · 3 min read Pandas filter a dataframe by the sum of rows or columns
Top answer
1 of 5
1

You can use .contains() by first converting them into str

res = df.loc[(df.index.astype(str).str.contains("2008-12")) 
             | (df.index.astype(str).str.contains('2008-11-05'))]
print(res)
                                             ts  val
ts                                                  
2008-11-05 07:45:23.100 2008-11-05 07:45:23.100    0
2008-12-02 07:36:18.643 2008-12-02 07:36:18.643    2
2008-12-15 07:36:24.837 2008-12-15 07:36:24.837    3

second question

yes you can apply filter on normal column like

df.loc[(df.ts.astype(str).str.contains("2008-12"))
    |(df.ts.astype(str).str.contains('2008-11-05'))]
2 of 5
1

This should be get going for you..

>>> df
                       ts  val
0 2008-11-05 07:45:23.100    0
1 2008-11-17 06:53:25.150    1
2 2008-12-02 07:36:18.643    2
3 2008-12-15 07:36:24.837    3
4 2009-01-06 07:03:47.387    4

Result:

>>> df[df.apply(lambda row: row.astype(str).str.contains('2008-11-05')).any(axis=1)]
                       ts  val
0 2008-11-05 07:45:23.100    0

OR ..

>>> df
                                             ts  val
ts
2008-11-05 07:45:23.100 2008-11-05 07:45:23.100    0
2008-11-17 06:53:25.150 2008-11-17 06:53:25.150    1
2008-12-02 07:36:18.643 2008-12-02 07:36:18.643    2
2008-12-15 07:36:24.837 2008-12-15 07:36:24.837    3
2009-01-06 07:03:47.387 2009-01-06 07:03:47.387    4

Result:

>>> df[df.apply(lambda row: row.astype(str).str.contains('2008-11-05')).any(axis=1)]
                                             ts  val
ts
2008-11-05 07:45:23.100 2008-11-05 07:45:23.100    0

Looking for multiple values.

>>> df[df.apply(lambda row: row.astype(str).str.contains('2008-11-05|2008-12')).any(axis=1)]
                                             ts  val
ts
2008-11-05 07:45:23.100 2008-11-05 07:45:23.100    0
2008-12-02 07:36:18.643 2008-12-02 07:36:18.643    2
2008-12-15 07:36:24.837 2008-12-15 07:36:24.837    3
🌐
GeeksforGeeks
geeksforgeeks.org › filter-pandas-dataframe-by-time
Filter Pandas DataFrame by Time | GeeksforGeeks
February 24, 2021 - There are possibilities of filtering data from Pandas dataframe with multiple conditions during the entire software development. Filter Pandas Dataframe with multiple conditionsThe reason is dataframe may be havi ... The DatetimeIndex contains datetime64[ns] data type, which represents timestamps with nanosecond precision.
🌐
CodeSignal
codesignal.com › learn › courses › basic-tsla-financial-data-handling-in-pandas › lessons › filtering-data-by-date-range-in-pandas
Filtering Data by Date Range in Pandas - Python
The first step in filtering data by date is to ensure that the date column is in a suitable format. Let's start by loading the Tesla ($TSLA) stock dataset and converting the "Date" column to datetime objects using pd.to_datetime(). import pandas as pd import datasets # Load TSLA dataset tesla_data = datasets.load_dataset('codesignal/tsla-historic-prices') tesla_df = pd.DataFrame(tesla_data['train']) # Convert the Date column to datetime type tesla_df['Date'] = pd.to_datetime(tesla_df['Date']) # Display initial rows to inspect the format print(tesla_df.head())
🌐
Linux find Examples
queirozf.com › entries › pandas-dataframe-examples-manipulating-date-and-time
Pandas Dataframe Examples: Manipulating Date and Time
September 17, 2022 - import pandas as pd df = pd.DataFrame({ "name":["alice","bob","charlie", "david"], "age":[12,43,22,34] }) # a timestamp column df["timestamp_col"] = pd.Timestamp(datetime.now()) # use strftime to turn a timestamp into a # a nicely formatted d-m-Y string: df["formatted_col"] = df["timestamp...