def testSetItem(self):
        df = DataFrame(self.table)
        df['id2'] = df.id + 1
        self.assertEqual(len(df.execute()), 3)

        df['id3'] = df['id2'] * 2
        self.assertEqual(len(next(df.execute())), 4)

        del df['id2']
        res = df.execute()
        result = self._get_result(res)

        expected = [[1, 'name1', 4], [2, 'name2', 6], [3, 'name3', 8]]
        self.assertEqual(expected, result)

        df = DataFrame(self.table)
        df['id2'] = df.id

        try:
            res = df.to_pandas()
            result = self._get_result(res)

            expected = [[1, 'name1', 1], [2, 'name2', 2], [3, 'name3', 3]]
            self.assertEqual(expected, result)
        except (DependencyNotInstalledError, ImportError):
            pass
    def testRepeatSetItem(self):
        df = DataFrame(self.table)

        df['rank'] = df.groupby('name').sort('id').id.rank()
        df['rank'] = df.groupby('name').sort('id').id.rank()

        self.assertEqual(len(df.execute()), 3)
Beispiel #3
0
 def testExecuteTable(self):
     self.create_iris(IRIS_TABLE)
     df = DataFrame(self.odps.get_table(IRIS_TABLE)).append_id()
     result = df.execute()
     self.assertIsInstance(result, ResultFrame)