Indexing dataframe by datetime python ignoring hour, minutes, seconds
<p>I have a pandas dataframe <code>df1</code> like the following, where the left hand column is in datetime index:</p>

<pre><code>2016-08-25 19:00:00  144.784598  171.696834  187.392857
2016-08-25 20:30:00  144.837891  171.800840  187.531250
2016-08-25 22:00:00  144.930882  171.982199  187.806134
2016-08-25 23:30:00  144.921652  171.939453  187.757102
2016-08-26 01:00:00  144.954799  172.014280  187.845094
2016-08-26 02:30:00  144.900528  171.906090  187.754032
2016-08-26 04:00:00  144.881981  171.828125  187.702679
2016-08-26 05:30:00  144.870937  171.794847  187.655016
2016-08-26 07:00:00  144.840892  171.728800  187.600116
2016-08-26 08:30:00  144.910801  172.001769  188.052317
2016-08-26 10:00:00  145.191640  172.668826  188.868579
2016-08-26 11:30:00  144.477707  171.294408  187.202932
2016-08-26 13:00:00  144.235066  170.835810  186.617500
2016-08-26 14:30:00  144.091562  170.449642  186.164453
2016-08-26 16:00:00  144.017857  170.404412  186.194444
2016-08-28 19:00:00  144.089375  170.459677  186.256250
2016-08-28 20:30:00  144.154567  170.632161  186.528646
2016-08-28 22:00:00  144.177083  170.701823  186.600694
2016-08-28 23:30:00  144.139063  170.636058  186.502604
2016-08-29 01:00:00  144.188802  170.714167  186.653846
2016-08-29 02:30:00  144.266544  170.760066  186.746094
2016-08-29 04:00:00  144.254464  170.792105  186.744420
2016-08-29 05:30:00  144.194643  170.707666  186.626008
2016-08-29 07:00:00  144.168080  170.633899  186.525962
2016-08-29 08:30:00  144.444046  171.226805  187.512533
2016-08-29 10:00:00  144.529018  171.356548  187.731343
2016-08-29 11:30:00  144.578200  171.421900  187.792991
2016-08-29 13:00:00  144.816134  171.924337  188.470633
2016-08-29 14:30:00  144.791319  171.947195  188.438232
2016-08-29 16:00:00  144.884115  172.066621  188.685855
2016-08-29 19:00:00  144.749023  171.873288  188.473404
2016-08-29 20:30:00  144.638091  171.656599  188.183036
2016-08-29 22:00:00  144.663889  171.687962  188.205729
2016-08-29 23:30:00  144.656414  171.689635  188.230183
2016-08-30 01:00:00  144.613005  171.620593  188.083008
2016-08-30 02:30:00  144.532600  171.503879  187.901940
2016-08-30 04:00:00  144.600160  171.569375  187.965000
2016-08-30 05:30:00  144.568487  171.646406  188.067871
2016-08-30 07:00:00  144.785362  171.930504  188.460526
2016-08-30 08:30:00  144.807596  171.831662  188.422468
2016-08-30 10:00:00  144.803997  171.709052  188.194496
2016-08-30 11:30:00  144.709896  171.518804  187.849864
2016-08-30 13:00:00  144.709727  171.573187  187.875962
2016-08-30 14:30:00  144.789761  171.729604  187.790865
2016-08-30 16:00:00  144.821875  171.800000  187.943484
2016-08-30 19:00:00  144.800781  171.762097  187.895833
2016-08-30 20:30:00  144.647727  171.568841  187.679688
2016-08-30 22:00:00  144.654974  171.559630  187.628125
2016-08-30 23:30:00  144.705163  171.652344  187.763672
2016-08-31 01:00:00  144.701202  171.608456  187.714286
2016-08-31 02:30:00  144.677083  171.620052  187.716250
2016-08-31 04:00:00  144.705056  171.551630  187.596755
2016-08-31 05:30:00  144.674479  171.470170  187.554688
2016-08-31 07:00:00  144.667969  171.509430  187.604167
2016-08-31 08:30:00  144.773438  171.754527  187.749107
2016-08-31 10:00:00  144.864793  171.762162  187.853659
2016-08-31 11:30:00  144.820976  171.686443  187.735577
2016-08-31 13:00:00  144.889785  172.005833  188.272672
2016-08-31 14:30:00  144.715252  171.757528  188.100291
2016-08-31 16:00:00  144.637500  171.680804  188.173611
</code></pre>

<p>I want to create a <code>df2</code> which just contains data from <code>2016-08-31</code> and <code>2016-08-30</code>. What's a way to utilize the datetime property to index these 2 days without having to loop through all the hour and minutes? The desired output for <code>df2</code> is:</p>

<pre><code>2016-08-30 01:00:00  144.613005  171.620593  188.083008
2016-08-30 02:30:00  144.532600  171.503879  187.901940
2016-08-30 04:00:00  144.600160  171.569375  187.965000
2016-08-30 05:30:00  144.568487  171.646406  188.067871
2016-08-30 07:00:00  144.785362  171.930504  188.460526
2016-08-30 08:30:00  144.807596  171.831662  188.422468
2016-08-30 10:00:00  144.803997  171.709052  188.194496
2016-08-30 11:30:00  144.709896  171.518804  187.849864
2016-08-30 13:00:00  144.709727  171.573187  187.875962
2016-08-30 14:30:00  144.789761  171.729604  187.790865
2016-08-30 16:00:00  144.821875  171.800000  187.943484
2016-08-30 19:00:00  144.800781  171.762097  187.895833
2016-08-30 20:30:00  144.647727  171.568841  187.679688
2016-08-30 22:00:00  144.654974  171.559630  187.628125
2016-08-30 23:30:00  144.705163  171.652344  187.763672
2016-08-31 01:00:00  144.701202  171.608456  187.714286
2016-08-31 02:30:00  144.677083  171.620052  187.716250
2016-08-31 04:00:00  144.705056  171.551630  187.596755
2016-08-31 05:30:00  144.674479  171.470170  187.554688
2016-08-31 07:00:00  144.667969  171.509430  187.604167
2016-08-31 08:30:00  144.773438  171.754527  187.749107
2016-08-31 10:00:00  144.864793  171.762162  187.853659
2016-08-31 11:30:00  144.820976  171.686443  187.735577
2016-08-31 13:00:00  144.889785  172.005833  188.272672
2016-08-31 14:30:00  144.715252  171.757528  188.100291
2016-08-31 16:00:00  144.637500  171.680804  188.173611
</code></pre>

<p>You can use strings to slice a datetime index:</p>

<pre><code>df.loc['2016-08-30':'2016-08-31']
Out: 
                              1           2           3
2016-08-30 01:00:00  144.613005  171.620593  188.083008
2016-08-30 02:30:00  144.532600  171.503879  187.901940
2016-08-30 04:00:00  144.600160  171.569375  187.965000
2016-08-30 05:30:00  144.568487  171.646406  188.067871
2016-08-30 07:00:00  144.785362  171.930504  188.460526
2016-08-30 08:30:00  144.807596  171.831662  188.422468
2016-08-30 10:00:00  144.803997  171.709052  188.194496
2016-08-30 11:30:00  144.709896  171.518804  187.849864
2016-08-30 13:00:00  144.709727  171.573187  187.875962
2016-08-30 14:30:00  144.789761  171.729604  187.790865
2016-08-30 16:00:00  144.821875  171.800000  187.943484
2016-08-30 19:00:00  144.800781  171.762097  187.895833
2016-08-30 20:30:00  144.647727  171.568841  187.679688
2016-08-30 22:00:00  144.654974  171.559630  187.628125
2016-08-30 23:30:00  144.705163  171.652344  187.763672
2016-08-31 01:00:00  144.701202  171.608456  187.714286
2016-08-31 02:30:00  144.677083  171.620052  187.716250
2016-08-31 04:00:00  144.705056  171.551630  187.596755
2016-08-31 05:30:00  144.674479  171.470170  187.554688
2016-08-31 07:00:00  144.667969  171.509430  187.604167
2016-08-31 08:30:00  144.773438  171.754527  187.749107
2016-08-31 10:00:00  144.864793  171.762162  187.853659
2016-08-31 11:30:00  144.820976  171.686443  187.735577
2016-08-31 13:00:00  144.889785  172.005833  188.272672
2016-08-31 14:30:00  144.715252  171.757528  188.100291
2016-08-31 16:00:00  144.637500  171.680804  188.173611
</code></pre>

python datetime pandas dataframe