示例#1
0
 def test4(self):
   return
   filepath = os.path.join(TEST_DIR, "test2_groupBy.pcl")
   fh = open(filepath, "rb")
   [category_values, grouping_values] = pickle.load(fh)
   fh.close()
   groups, grouped_values = groupBy(category_values, grouping_values)
示例#2
0
 def test4(self):
     return
     filepath = os.path.join(TEST_DIR, "test2_groupBy.pcl")
     fh = open(filepath, "rb")
     [category_values, grouping_values] = pickle.load(fh)
     fh.close()
     groups, grouped_values = groupBy(category_values, grouping_values)
示例#3
0
 def test5(self):
     category_values = [0, 1, 1, 1, 2, 3]
     grouping_values = [
         0.069000000000000006, 0.014999999999999999, 0.069000000000000006,
         0.021000000000000001, 0.027, 0.027
     ]
     groups, grouped_values = groupBy(category_values, grouping_values)
     self.assertTrue(groups == range(4))
示例#4
0
 def test2(self):
   cats = [self.df['cat1'], self.df['cat2']]
   groups, values = groupBy(cats, self.df['bb'])
   self.assertTrue(groups == zip(CAT1, CAT2))
   self.assertEqual(len(values), len(groups))
   for idx in range(len(groups)):
     if groups[idx] == ('a', 'x'):
       self.assertTrue(list(values[idx]) == [0, 4])
     if groups[idx] == ('a', 'y'):
       self.assertTrue(list(values[idx]) == [1, 5])
     if groups[idx] == ('b', 'x'):
       self.assertTrue(list(values[idx]) == [2, 6])
     if groups[idx] == ('b', 'y'):
       self.assertTrue(list(values[idx]) == [3, 7])
示例#5
0
 def test2(self):
     cats = [self.df['cat1'], self.df['cat2']]
     groups, values = groupBy(cats, self.df['bb'])
     self.assertTrue(groups == zip(CAT1, CAT2))
     self.assertEqual(len(values), len(groups))
     for idx in range(len(groups)):
         if groups[idx] == ('a', 'x'):
             self.assertTrue(list(values[idx]) == [0, 4])
         if groups[idx] == ('a', 'y'):
             self.assertTrue(list(values[idx]) == [1, 5])
         if groups[idx] == ('b', 'x'):
             self.assertTrue(list(values[idx]) == [2, 6])
         if groups[idx] == ('b', 'y'):
             self.assertTrue(list(values[idx]) == [3, 7])
示例#6
0
 def test6(self):
     category_values = [u'0', u'1', u'1', u'1', u'2', u'3', u'4']
     grouping_values = [
         0.069000000000000006, 0.014999999999999999, 0.069000000000000006,
         0.021000000000000001, 0.027, 0.027, 0.027, np.nan, np.nan, np.nan,
         np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
         np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
         np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
         np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
         np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
         np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
         np.nan, np.nan, np.nan, np.nan, np.nan, np.nan
     ]
     groups, grouped_values = groupBy(category_values, grouping_values)
     self.assertEqual(len(groups), 5)
示例#7
0
 def test6(self):
   category_values = [u'0', u'1', u'1', u'1', u'2', u'3', u'4']
   grouping_values = [0.069000000000000006, 0.014999999999999999, 0.069000000000000006, 0.021000000000000001, 0.027, 0.027, 0.027, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]
   groups, grouped_values = groupBy(category_values, grouping_values)
   self.assertEqual(len(groups), 5)
示例#8
0
 def test5(self):
   category_values = [0, 1, 1, 1, 2, 3]
   grouping_values = [0.069000000000000006, 0.014999999999999999, 0.069000000000000006, 0.021000000000000001, 0.027, 0.027]
   groups, grouped_values = groupBy(category_values, grouping_values)
   self.assertTrue(groups == range(4))
示例#9
0
 def test1(self):
   groups, values = groupBy([self.df['cat1']], self.df['cc'])
   self.assertTrue(set(groups) == set(CAT1))
   self.assertEqual(len(values), len(groups))
   self.assertTrue(list(roundValues(values[0])) == [0, 0.1, 0.4, 0.5])
   self.assertTrue(list(roundValues(values[1])) == [0.2, 0.3, 0.6, 0.7])
示例#10
0
 def test1(self):
     groups, values = groupBy([self.df['cat1']], self.df['cc'])
     self.assertTrue(set(groups) == set(CAT1))
     self.assertEqual(len(values), len(groups))
     self.assertTrue(list(roundValues(values[0])) == [0, 0.1, 0.4, 0.5])
     self.assertTrue(list(roundValues(values[1])) == [0.2, 0.3, 0.6, 0.7])