def test_parse_date_fields():
    days = np.array([3, 4])
    months = np.array([1, 2])
    years = np.array([2007, 2008])
    result = conv.parse_date_fields(years, months, days)

    expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
    tm.assert_numpy_array_equal(result, expected)
Beispiel #2
0
def test_parse_date_fields():
    days = np.array([3, 4])
    months = np.array([1, 2])
    years = np.array([2007, 2008])
    result = conv.parse_date_fields(years, months, days)

    expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
    tm.assert_numpy_array_equal(result, expected)
Beispiel #3
0
def test_parse_date_fields():
    days = np.array([3, 4])
    months = np.array([1, 2])
    years = np.array([2007, 2008])
    expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])

    with tm.assert_produces_warning(FutureWarning):
        result = conv.parse_date_fields(years, months, days)
    tm.assert_numpy_array_equal(result, expected)
    def test_parse_date_fields(self):
        result = conv.parse_date_fields(self.years, self.months, self.days)
        expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
        self.assertTrue((result == expected).all())

        data = "year, month, day, a\n 2001 , 01 , 10 , 10.\n 2001 , 02 , 1 , 11."
        datecols = {"ymd": [0, 1, 2]}
        df = read_table(StringIO(data), sep=",", header=0, parse_dates=datecols, date_parser=conv.parse_date_fields)
        self.assertIn("ymd", df)
        self.assertEqual(df.ymd.ix[0], datetime(2001, 1, 10))
Beispiel #5
0
    def test_parse_date_fields(self):
        result = conv.parse_date_fields(self.years, self.months, self.days)
        expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
        self.assert_((result == expected).all())

        data = "year, month, day, a\n 2001 , 01 , 10 , 10.\n 2001 , 02 , 1 , 11."
        datecols = {'ymd': [0, 1, 2]}
        df = read_table(StringIO(data), sep=',', header=0,
                        parse_dates=datecols,
                        date_parser=conv.parse_date_fields)
        self.assert_('ymd' in df)
        self.assert_(df.ymd.ix[0] == datetime(2001, 1, 10))
Beispiel #6
0
    def test_parse_date_fields(self):
        years = np.array([2007, 2008])
        months = np.array([1, 2])
        days = np.array([3, 4])
        result = conv.parse_date_fields(years, months, days)
        expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
        assert (result == expected).all()

        data = ("year, month, day, a\n 2001 , 01 , 10 , 10.\n"
                "2001 , 02 , 1 , 11.")
        datecols = {'ymd': [0, 1, 2]}
        df = self.read_csv(StringIO(data), sep=',', header=0,
                           parse_dates=datecols,
                           date_parser=conv.parse_date_fields)
        assert 'ymd' in df
        assert df.ymd.loc[0] == datetime(2001, 1, 10)
    def test_parse_date_fields(self):
        years = np.array([2007, 2008])
        months = np.array([1, 2])
        days = np.array([3, 4])
        result = conv.parse_date_fields(years, months, days)
        expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
        assert (result == expected).all()

        data = ("year, month, day, a\n 2001 , 01 , 10 , 10.\n"
                "2001 , 02 , 1 , 11.")
        datecols = {'ymd': [0, 1, 2]}
        df = self.read_csv(StringIO(data), sep=',', header=0,
                           parse_dates=datecols,
                           date_parser=conv.parse_date_fields)
        assert 'ymd' in df
        assert df.ymd.loc[0] == datetime(2001, 1, 10)