October 2017
Intermediate to advanced
532 pages
16h 10m
English
Once we ensure that our index is a DatetimeIndex, we can take advantage of all the methods in this recipe. It is impossible to do selection or slicing based on just the time component of a Timestamp with the .loc indexer. To select all dates by a range of time, you must use the between_time method, or to select an exact time, use at_time. Make sure that the passed string for start and end times consists of at least the hour and minute. It is also possible to use time objects from the datetime module. For instance, the following command would yield the same result as in step 2:
>>> import datetime>>> crime.between_time(datetime.time(2,0), datetime.time(5,0), include_end=False)
In step 4, we begin using the simple first method, ...
Read now
Unlock full access