You can compare with datetime
format like this:
Suppose:
import pandas as pd
import datetime
df = pd.DataFrame({'col1':['2017-05-24 09:06:11','2017-05-24 09:06:12','2017-05-24 09:00:00'], 'col2':['hello','hi','bonjour']})
df.columns=['DNT','tweets']
df.DNT = pd.to_datetime(df.DNT, errors='coerce')
df
df
will be:
DNT tweets
0 2017-05-24 09:06:11 hello
1 2017-05-24 09:06:12 hi
2 2017-05-24 09:00:00 bonjour
Then you can compare with start
and end
:
end = datetime.datetime(2017, 5, 24, 9, 20) #2017-05-24 09:20:00
start = datetime.datetime(2017, 5, 24, 9) #2017-05-24 09:00:00
df[ (df.DNT < end) & (df.DNT > start) ]
Then filter result will be:
DNT tweets
0 2017-05-24 09:06:11 hello
1 2017-05-24 09:06:12 hi