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 - 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
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
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
🌐
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....
🌐
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
🌐
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 - The date_range() function can be used in combination with boolean indexing to filter DataFrame rows within a specific date range. By creating a date range, you can easily filter out rows that do not fall within this range. ... import pandas as pd # Creating a sample DataFrame with a time column ...
🌐
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
🌐
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.
Find elsewhere
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.between_time.html
pandas.DataFrame.between_time — pandas 3.0.6 documentation
By setting start_time to be later than end_time, you can get the times that are not between the two times. ... Initial time as a time filter limit.
🌐
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 can also filter by last N months, Since there is no month argument for pd.Timedelta so the work around is to get the month of last date and subtract N to it. ... Alternatively, we can use pd.offsets() also but that throws a warning that comparison of Timestamp with datetime.date is deprecated and use pd.Timestamp(date) or ts.date() == date instead
🌐
GPT Tutor Pro
gpttutorpro.com › pandas-dataframe-filtering-using-datetime-methods
Pandas DataFrame Filtering: Using Datetime Methods
March 12, 2024 - This blog will teach you how to use datetime methods in Pandas to filter data based on dates and times. 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.
🌐
Iditect
iditect.com › faq › python › filterselect-rows-of-pandas-dataframe-by-timestamp-column.html
Filter/select rows of pandas dataframe by timestamp column
In this example, we first convert the 'timestamp' column to a Pandas datetime object using pd.to_datetime(). Then, we define the start_date and end_date to specify the range of timestamps we want to select. Finally, we use boolean indexing to filter rows within the specified timestamp range.
🌐
DataScientYst
datascientyst.com › filter-by-date-pandas-dataframe
How to Filter DataFrame by Date in Pandas
December 2, 2021 - You can use pd.Timestamp in order to construct your dates and compare the value with each row. The syntax for creating a date with Pandas is: ... You can pass a string like in option 1 and Pandas will do the conversion for you. This can be useful when conversion is not explicit or you like to have control on the format. Pandas offers a simple way to query rows by method query. ... Finally let's check several useful and frequently used filters...
🌐
GeeksforGeeks
geeksforgeeks.org › python › filter-pandas-dataframe-by-time
Filter Pandas DataFrame by Time - GeeksforGeeks
July 23, 2025 - import pandas as pd # create data frame Data = {'Name': ['Mukul', 'Rohan', 'Mayank', 'Shubham', 'Aakash'], 'DOB': ['1997-04-24', '1998-05-25', '1999-04-11', '2000-11-15', '1998-06-28']} df = pd.DataFrame(Data) # print original data frame print(df) # filter data frame New_df = df.loc[df["DOB"] >= "1999-02-5"] # print filtered data frame print(New_df)
🌐
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 - We can change them from Integers to Float type, Integer to Datetime, String to Integer, Float to Datetime, etc. For converting float to DateTime we use pandas.to_datetime() function and following syntax is used : Syntax: 3 min read How to Group ...
🌐
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...
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
🌐
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
With the date column converted to datetime objects, set as the index, and sorted, we can now filter the DataFrame by a specific date range. This technique is particularly useful when you need to analyze data for a specific year, month, or any custom date range.