def test_datetime_six_col(self): years = np.array([2007, 2008]) months = np.array([1, 2]) days = np.array([3, 4]) hours = np.array([5, 6]) minutes = np.array([7, 8]) seconds = np.array([9, 0]) expected = np.array([datetime(2007, 1, 3, 5, 7, 9), datetime(2008, 2, 4, 6, 8, 0)]) result = conv.parse_all_fields(years, months, days, hours, minutes, seconds) assert (result == expected).all() data = """\ year, month, day, hour, minute, second, a, b 2001, 01, 05, 10, 00, 0, 0.0, 10. 2001, 01, 5, 10, 0, 00, 1., 11. """ datecols = {'ymdHMS': [0, 1, 2, 3, 4, 5]} df = self.read_csv(StringIO(data), sep=',', header=0, parse_dates=datecols, date_parser=conv.parse_all_fields) assert 'ymdHMS' in df assert df.ymdHMS.loc[0] == datetime(2001, 1, 5, 10, 0, 0)
def test_datetime_six_col(self): years = np.array([2007, 2008]) months = np.array([1, 2]) days = np.array([3, 4]) hours = np.array([5, 6]) minutes = np.array([7, 8]) seconds = np.array([9, 0]) expected = np.array( [datetime(2007, 1, 3, 5, 7, 9), datetime(2008, 2, 4, 6, 8, 0)]) result = conv.parse_all_fields(years, months, days, hours, minutes, seconds) assert (result == expected).all() data = """\ year, month, day, hour, minute, second, a, b 2001, 01, 05, 10, 00, 0, 0.0, 10. 2001, 01, 5, 10, 0, 00, 1., 11. """ datecols = {'ymdHMS': [0, 1, 2, 3, 4, 5]} df = self.read_csv(StringIO(data), sep=',', header=0, parse_dates=datecols, date_parser=conv.parse_all_fields) assert 'ymdHMS' in df assert df.ymdHMS.loc[0] == datetime(2001, 1, 5, 10, 0, 0)
def test_parse_all_fields(): hours = np.array([5, 6]) minutes = np.array([7, 8]) seconds = np.array([9, 0]) days = np.array([3, 4]) years = np.array([2007, 2008]) months = np.array([1, 2]) result = conv.parse_all_fields(years, months, days, hours, minutes, seconds) expected = np.array([datetime(2007, 1, 3, 5, 7, 9), datetime(2008, 2, 4, 6, 8, 0)]) tm.assert_numpy_array_equal(result, expected)
def test_datetime_six_col(self): result = conv.parse_all_fields(self.years, self.months, self.days, self.hours, self.minutes, self.seconds) self.assertTrue((result == self.expected).all()) data = """\ year, month, day, hour, minute, second, a, b 2001, 01, 05, 10, 00, 0, 0.0, 10. 2001, 01, 5, 10, 0, 00, 1., 11. """ datecols = {"ymdHMS": [0, 1, 2, 3, 4, 5]} df = read_table(StringIO(data), sep=",", header=0, parse_dates=datecols, date_parser=conv.parse_all_fields) self.assertIn("ymdHMS", df) self.assertEqual(df.ymdHMS.ix[0], datetime(2001, 1, 5, 10, 0, 0))
def test_parse_all_fields(): hours = np.array([5, 6]) minutes = np.array([7, 8]) seconds = np.array([9, 0]) days = np.array([3, 4]) years = np.array([2007, 2008]) months = np.array([1, 2]) result = conv.parse_all_fields(years, months, days, hours, minutes, seconds) expected = np.array([datetime(2007, 1, 3, 5, 7, 9), datetime(2008, 2, 4, 6, 8, 0)]) tm.assert_numpy_array_equal(result, expected)
def test_datetime_six_col(self): result = conv.parse_all_fields(self.years, self.months, self.days, self.hours, self.minutes, self.seconds) self.assert_((result == self.expected).all()) data = """\ year, month, day, hour, minute, second, a, b 2001, 01, 05, 10, 00, 0, 0.0, 10. 2001, 01, 5, 10, 0, 00, 1., 11. """ datecols = {'ymdHMS': [0, 1, 2, 3, 4, 5]} df = read_table(StringIO(data), sep=',', header=0, parse_dates=datecols, date_parser=conv.parse_all_fields) self.assert_('ymdHMS' in df) self.assert_(df.ymdHMS.ix[0] == datetime(2001, 1, 5, 10, 0, 0))