Exemple #1
0
class TestPandasSourceWithIndexCount(CountTests, unittest.TestCase):
    def setUp(self):
        df = pandas.DataFrame(self.testdata, columns=self.fieldnames)
        df = df.set_index(['label1', 'label2'])  # <- Specify index!
        self.datasource = PandasSource(df)

    def test_compound_keys(self):
        expected = {
            ('a', 'x'): 2,
            ('a', 'y'): 1,
            ('a', ''): 1,
            ('b', 'z'): 1,
            ('b', 'y'): 1,
            ('b', 'x'): 1,
            #('b', None): 1,
            ('b', pandas.np.nan): 1,  # <- Returns nan instead of None (and that's OK!).
            ('b', ''): 1,
        }
        result = self.datasource.count('label1', ['label1', 'label2'])
        self.assertEqual(expected, result)
Exemple #2
0
 def setUp(self):
     df = pandas.DataFrame(self.testdata, columns=self.fieldnames)
     df = df.set_index(['label1', 'label2'])
     #df = df.set_index(['label1'])
     self.datasource = PandasSource(df)
Exemple #3
0
 def setUp(self):
     df = pandas.DataFrame(self.testdata, columns=self.fieldnames)
     self.datasource = PandasSource(df)