Example #1
0
	def test_transform_object(self):
		mapping = {tuple(["zero"]) : "null", ("one", True) : "ein", ("two", True) : "zwei", ("three", True) : "drei"}
		with self.assertRaises(ValueError):
			MultiLookupTransformer(mapping, None)
		mapping.pop(tuple(["zero"]))
		transformer = MultiLookupTransformer(mapping, None)
		Y = DataFrame([["one", None], ["one", True], [None, True], ["two", True], ["three", True]])
		Yt = transformer.transform(Y)
		self.assertEqual([None, "ein", None, "zwei", "drei"], Yt.tolist())
		Y = numpy.matrix([["one", True], ["one", None], ["two", True]], dtype = "O")
		Yt = transformer.transform(Y)
		self.assertEqual(["ein", None, "zwei"], Yt.tolist())
Example #2
0
 def test_transform_int(self):
     mapping = {(1, 1): "one", (2, 2): "two", (3, 3): "three"}
     transformer = MultiLookupTransformer(mapping, None)
     X = DataFrame([[1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1],
                    [3, 2], [3, 3]])
     self.assertEqual([[None], ["one"], [None], [None], ["two"], [None],
                       [None], [None], ["three"]],
                      transformer.transform(X).tolist())
Example #3
0
 def test_transform_int(self):
     mapping = {(1, 1): "one", (2, 2): "two", (3, 3): "three"}
     transformer = MultiLookupTransformer(mapping, None)
     Y = DataFrame([[1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1],
                    [3, 2], [3, 3]])
     Yt = transformer.transform(Y)
     self.assertEqual(
         [None, "one", None, None, "two", None, None, None, "three"],
         Yt.tolist())