Python Pandas .Apply Function to Vectorized Form
<p>I'm trying to convert the following .apply transformation to a vectorized form which will run faster.  I've tried .where, and I've tried normal boolean indexing, however my solutions are not working.  Please send me in the right direction</p>

<pre><code>oneDayDelta = datetime.timedelta(days=1)
def correct_gps_datetimestamp(row):
    new_dts = row['GPS_DateTime']
    if row['Created'].hour == 0 and  row['GPS_DateTime'].hour &gt; 10:
        new_dts = row['GPS_DateTime'] - oneDayDelta
    return(new_dts)

allData['GPS_DateTime'] = allData.apply(correct_gps_datetimestamp,axis=1)
</code></pre>

<p>Non working solution:</p>

<pre><code>allData['GPS_DateTime'] = allData.where(allData['Created'].hour == 0 &amp; allData['GPS_DateTime'].hour &gt; 10,allData['GPS_DateTime'] - datetime.timedelta(days=1))
</code></pre>

<p>I think you need add <code>()</code> only to conditions:</p>

<pre><code>(allData['Created'].hour == 0) &amp; (allData['GPS_DateTime'].hour &gt; 10)
</code></pre>

<hr>

<pre><code>allData['GPS_DateTime'] = allData.where((allData['Created'].hour == 0) &amp; 
                                        (allData['GPS_DateTime'].hour &gt; 10),
                                        allData['GPS_DateTime'] - datetime.timedelta(days=1))
</code></pre>

python pandas