Selecting a rows from a panda frame based on a time that has been converted into datetime format and stripped from a POSIX time stamp, python
<p>I am using the code below to pull data from Google Finance. The timestamp is in POSIX form, so it is converted into data time. When I try to fiter it based on a time criteria <strong>(14:35:00)</strong>, it returns an empty table. I suspect it has to do with the POSIX/ datetime conversion, but have no idea how to resolve it.</p>

<pre><code>def get_intraday_data(symbol, interval_seconds=301, num_days=10):
    # Specify URL string based on function inputs.
    url_string = 'http://www.google.com/finance/getprices?q={0}'.format(symbol.upper())
    url_string += "&amp;i={0}&amp;p={1}d&amp;f=d,o,h,l,c,v".format(interval_seconds,num_days)

    # Request the text, and split by each line
    r = requests.get(url_string).text.split()

    # Split each line by a comma, starting at the 8th line
    r = [line.split(',') for line in r[7:]]

    # Save data in Pandas DataFrame
    df = pd.DataFrame(r, columns=['Datetime','Close','High','Low','Open','Volume'])

    # Convert UNIX to Datetime format
    df['Datetime'] = df['Datetime'].apply(lambda x: datetime.datetime.fromtimestamp(int(x[1:])))

    #Seperate Date and Time
    df['Time'],df['Date']= df['Datetime'].apply(lambda x:x.time()), df['Datetime'].apply(lambda x:x.date()) 

    #Convert 'Close','High','Low','Open', deleting 'Volume'

''''df['Close'] = df['Close'].astype('float64')
df['High'] = df['High'].astype('float64')
df['Low'] = df['Low'].astype('float64')
df['Open'] = df['Open'].astype('float64')'''
    del df['Volume']
    del df['Datetime']

    df[['Close','High','Low','Open']]  = df[['Close','High','Low','Open']].astype('float64')

   # Calculating %Change and Range 

    df['%pct'] = (df['Close'] - df['Open'])/df['Open']
    df['Range'] = df['High'] - df['Low']

    #Sort Columns


    return df
</code></pre>

<p>I have stored the results of this function as <strong>NAS</strong></p>

<pre><code>NAS = get_intraday_data('IXIC', interval_seconds=301, num_days= 100)
</code></pre>

<p>The Filter Criteria is:</p>

<pre><code>NAS[NAS['Time'] == '14:35:00']
</code></pre>

<p>I will appreciate assistance on this.</p>

<p>You can use this </p>

<pre><code>NAS.query('Datetime.dt.hour==14 and Datetime.dt.minute==35 and Datetime.dt.second==0')
</code></pre>

<p><strong>Edit:</strong>
Applied dt on datetime series instead of time series</p>

<pre><code>raw_data = {'Datetime': ['2015-05-01T14:35:00', '2016-07-04T02:26:00', '2013-02-01T04:41:00']}
df = pd.DataFrame(raw_data, columns = ['Datetime'])
df["Datetime"] = pd.to_datetime(df["Datetime"])
df['Time'],df['Date']= df['Datetime'].apply(lambda x:x.time()), df['Datetime'].apply(lambda x:x.date()) 
df = df.set_index(df["Datetime"])
df['hour']=df['Datetime'].dt.hour
df['minute']=df['Datetime'].dt.minute
df['second']=df['Datetime'].dt.second
df.query('Datetime.dt.hour==14 and Datetime.dt.minute==35 and Datetime.dt.second==0')
</code></pre>

python python-3.x datetime pandas posixlt