Esempio n. 1
0
    def test_pivot(self):
        from pandas.core.reshape import _slow_pivot

        one, two, three = (np.array([1, 2, 3, 4, 5]), np.array(["a", "b", "c", "d", "e"]), np.array([1, 2, 3, 5, 4.0]))
        df = pivot(one, two, three)
        self.assertEqual(df["a"][1], 1)
        self.assertEqual(df["b"][2], 2)
        self.assertEqual(df["c"][3], 3)
        self.assertEqual(df["d"][4], 5)
        self.assertEqual(df["e"][5], 4)
        assert_frame_equal(df, _slow_pivot(one, two, three))

        # weird overlap, TODO: test?
        a, b, c = (np.array([1, 2, 3, 4, 4]), np.array(["a", "a", "a", "a", "a"]), np.array([1.0, 2.0, 3.0, 4.0, 5.0]))
        self.assertRaises(Exception, pivot, a, b, c)

        # corner case, empty
        df = pivot(np.array([]), np.array([]), np.array([]))
Esempio n. 2
0
    def test_pivot(self):
        from pandas.core.reshape import _slow_pivot

        df = pivot(np.array([1, 2, 3, 4, 5]), np.array(["a", "b", "c", "d", "e"]), np.array([1, 2, 3, 5, 4.0]))
        self.assertEqual(df["a"][1], 1)
        self.assertEqual(df["b"][2], 2)
        self.assertEqual(df["c"][3], 3)
        self.assertEqual(df["d"][4], 5)
        self.assertEqual(df["e"][5], 4)

        # weird overlap, TODO: test?
        a, b, c = (np.array([1, 2, 3, 4, 4]), np.array(["a", "a", "a", "a", "a"]), np.array([1.0, 2.0, 3.0, 4.0, 5.0]))
        df = pivot(a, b, c)
        expected = _slow_pivot(a, b, c)
        assert_frame_equal(df, expected)

        # corner case, empty
        df = pivot(np.array([]), np.array([]), np.array([]))
Esempio n. 3
0
    def test_pivot(self):
        from pandas.core.reshape import _slow_pivot

        one, two, three = (np.array([1, 2, 3, 4, 5]),
                           np.array(['a', 'b', 'c', 'd', 'e']),
                           np.array([1, 2, 3, 5, 4.]))
        df = pivot(one, two, three)
        self.assertEqual(df['a'][1], 1)
        self.assertEqual(df['b'][2], 2)
        self.assertEqual(df['c'][3], 3)
        self.assertEqual(df['d'][4], 5)
        self.assertEqual(df['e'][5], 4)
        assert_frame_equal(df, _slow_pivot(one, two, three))

        # weird overlap, TODO: test?
        a, b, c = (np.array([1, 2, 3, 4, 4]),
                   np.array(['a', 'a', 'a', 'a', 'a']),
                   np.array([1., 2., 3., 4., 5.]))
        self.assertRaises(Exception, pivot, a, b, c)

        # corner case, empty
        df = pivot(np.array([]), np.array([]), np.array([]))
Esempio n. 4
0
    def test_pivot(self):
        from pandas.core.reshape import _slow_pivot

        one, two, three = (np.array([1, 2, 3, 4,
                                     5]), np.array(['a', 'b', 'c', 'd', 'e']),
                           np.array([1, 2, 3, 5, 4.]))
        df = pivot(one, two, three)
        self.assertEqual(df['a'][1], 1)
        self.assertEqual(df['b'][2], 2)
        self.assertEqual(df['c'][3], 3)
        self.assertEqual(df['d'][4], 5)
        self.assertEqual(df['e'][5], 4)
        assert_frame_equal(df, _slow_pivot(one, two, three))

        # weird overlap, TODO: test?
        a, b, c = (np.array([1, 2, 3, 4,
                             4]), np.array(['a', 'a', 'a', 'a', 'a']),
                   np.array([1., 2., 3., 4., 5.]))
        self.assertRaises(Exception, pivot, a, b, c)

        # corner case, empty
        df = pivot(np.array([]), np.array([]), np.array([]))