Added snippet for datetime replace. When aggregating or grouping time series data, it is sometimes

useful to replace fields of a series of datetimes such as zeroing
        out the minute and second fields.
This commit is contained in:
Donne Martin 2015-01-24 08:14:50 -05:00
parent 9215edb560
commit 4c6bcef382

View File

@ -42,3 +42,10 @@ class TestDateUtil():
"""Convert/parse string into datetime objects"""
d = datetime(self.year, self.month, self.day)
assert_equal(datetime.strptime('20150120', '%Y%m%d'), d)
def test_datetime_replace(self):
"""When aggregating or grouping time series data, it is sometimes
useful to replace fields of a series of datetimes such as zeroing
out the minute and second fields."""
dt = datetime(self.year, self.month, self.day, self.hour, 0, 0)
assert_equal(self.dt.replace(minute=0, second=0), dt)