Esempio n. 1
0
	def test_normalize(self):
		X = numpy.asarray([" One", " two ", "THRee "])
		normalizer = StringNormalizer(function = None)
		self.assertEqual(["One", "two", "THRee"], normalizer.transform(X).tolist())
		normalizer = StringNormalizer(function = "uppercase", trim_blanks = False)
		self.assertEqual([" ONE", " TWO ", "THREE "], normalizer.transform(X).tolist())
		normalizer = StringNormalizer(function = "lowercase")
		self.assertEqual(["one", "two", "three"], normalizer.transform(X).tolist())
		X = Series(X, dtype = str)
		self.assertEqual(["one", "two", "three"], normalizer.transform(X).tolist())
Esempio n. 2
0
	def test_transform(self):
		X = numpy.asarray([" One", " two ", "THRee "])
		normalizer = StringNormalizer(function = None)
		self.assertEqual(["One", "two", "THRee"], normalizer.transform(X).tolist())
		normalizer = StringNormalizer(function = "uppercase", trim_blanks = False)
		self.assertEqual([" ONE", " TWO ", "THREE "], normalizer.transform(X).tolist())
		normalizer = StringNormalizer(function = "lowercase")
		self.assertEqual(["one", "two", "three"], normalizer.transform(X).tolist())
		X = X.reshape(3, 1)
		self.assertEqual([["one"], ["two"], ["three"]], normalizer.transform(X).tolist())