Example #1
0
 def test_gr_6(self):
     groupby_reduce.groupby_reduce(self.infile_1, self.outfile, ',',
                                   ['name', 'cit'], 'age', ['mean'])
     results = self.outfile.getvalue()
     self.assertEqual(
         results,
         'name,cit|mean\r\ndan,uk|22.0\r\nian,uk|11.0\r\nian,us|56.0\r\ndan'
         ',fr|2.0\r\n')
Example #2
0
 def test_gr_1(self):
     groupby_reduce.groupby_reduce(self.infile_1, self.outfile, ',',
                                   ['name'], 'age',
                                   ['count', 'mean', 'sum'])
     results = self.outfile.getvalue()
     self.assertEqual(
         results, 'name|count|mean|sum\r\ndan|2|12.0|24.0\r\nian|3|41.0|'
         '123.0\r\n')
Example #3
0
 def test_gr_2(self):
     groupby_reduce.groupby_reduce(self.infile_1, self.outfile, ',',
                                   ['name', 'cit'], 'age',
                                   ['count', 'mean', 'sum'])
     results = self.outfile.getvalue()
     self.assertEqual(
         results,
         'name,cit|count|mean|sum\r\ndan,uk|1|22.0|22.0\r\nian,uk|1'
         '|11.0|11.0\r\nian,us|2|56.0|112.0\r\ndan,fr|1|2.0|2.0\r\n')
Example #4
0
 def test_gr_5(self):
     groupby_reduce.groupby_reduce(self.infile_1, self.outfile, ',',
                                   ['name', 'cit'], 'other', ['sum'])
     results = self.outfile.getvalue()
     self.assertEqual(results,
                      'name,cit|sum\r\ndan,fr|7.0\r\nian,us|4.0\r\n')
Example #5
0
 def test_gr_4(self):
     groupby_reduce.groupby_reduce(self.infile_1, self.outfile, ',',
                                   ['name', 'other'], 'age', ['sum'])
     results = self.outfile.getvalue()
     self.assertEqual(results,
                      'name,other|sum\r\nian,2|112.0\r\ndan,7|2.0\r\n')
Example #6
0
 def test_gr_4(self):
     groupby_reduce.groupby_reduce(self.infile_1, self.outfile, ',',
                                   ['name'], None, [])
     results = self.outfile.getvalue()
     self.assertEqual(results, 'name\r\ndan\r\nian\r\n')