Exemple #1
0
    def test_that_parse_data_works_properly(self):
        test_schema = {'fields': [{'mode': 'NULLABLE', 'name': 'VALID_STRING', 'type': 'STRING'}]}
        test_page = [{'f': [{'v': 'PI'}]}]

        test_output = gbq._parse_data(test_schema, test_page)
        correct_output = DataFrame({'VALID_STRING': ['PI']})
        tm.assert_frame_equal(test_output, correct_output)
    def test_that_parse_data_works_properly(self):
        test_schema = {'fields': [{'mode': 'NULLABLE', 'name': 'VALID_STRING', 'type': 'STRING'}]}
        test_page = [{'f': [{'v': 'PI'}]}]

        test_output = gbq._parse_data(test_schema, test_page)
        correct_output = DataFrame({'VALID_STRING': ['PI']})
        tm.assert_frame_equal(test_output, correct_output)
Exemple #3
0
    def test_that_parse_data_works_properly(self):
        test_schema = {"fields": [{"mode": "NULLABLE", "name": "VALID_STRING", "type": "STRING"}]}
        test_page = [{"f": [{"v": "PI"}]}]

        test_output = gbq._parse_data(test_schema, test_page)
        correct_output = DataFrame({"VALID_STRING": ["PI"]})
        tm.assert_frame_equal(test_output, correct_output)
Exemple #4
0
 def test_index_column(self):
     # A user should be able to specify an index column for return
     result_frame = gbq._parse_data(FakeClient(),
                                    self.fake_job,
                                    index_col='word')
     correct_frame = DataFrame(self.correct_data_small)
     correct_frame.set_index('word', inplace=True)
     self.assertTrue(result_frame.index.name == correct_frame.index.name)
Exemple #5
0
 def test_column_order(self):
     # A User should be able to specify the order in which columns are returned in the dataframe
     col_order = ['corpus_date', 'word_count', 'corpus', 'word']
     result_frame = gbq._parse_data(FakeClient(),
                                    self.fake_job,
                                    col_order=col_order)
     tm.assert_index_equal(
         result_frame.columns,
         DataFrame(self.correct_data_small)[col_order].columns)
Exemple #6
0
 def test_column_order_plus_index(self):
     # A User should be able to specify an index and the order of THE REMAINING columns.. they should be notified
     # if they screw up
     col_order = ['corpus_date', 'word', 'corpus']
     result_frame = gbq._parse_data(FakeClient(), self.fake_job, index_col='word_count', col_order=col_order)
     correct_frame_small = DataFrame(self.correct_data_small)
     correct_frame_small.set_index('word_count',inplace=True)
     correct_frame_small = DataFrame(correct_frame_small)[col_order]
     tm.assert_index_equal(result_frame.columns, correct_frame_small.columns)
Exemple #7
0
 def test_column_order_plus_index(self):
     # A User should be able to specify an index and the order of THE REMAINING columns.. they should be notified
     # if they screw up
     col_order = ['corpus_date', 'word', 'corpus']
     result_frame = gbq._parse_data(FakeClient(),
                                    self.fake_job,
                                    index_col='word_count',
                                    col_order=col_order)
     correct_frame_small = DataFrame(self.correct_data_small)
     correct_frame_small.set_index('word_count', inplace=True)
     correct_frame_small = DataFrame(correct_frame_small)[col_order]
     tm.assert_index_equal(result_frame.columns,
                           correct_frame_small.columns)
Exemple #8
0
 def test_column_order(self):
     # A User should be able to specify the order in which columns are returned in the dataframe    
     col_order = ['corpus_date', 'word_count', 'corpus', 'word']
     result_frame = gbq._parse_data(FakeClient(), self.fake_job, col_order=col_order)
     tm.assert_index_equal(result_frame.columns, DataFrame(self.correct_data_small)[col_order].columns)
Exemple #9
0
 def test_index_column(self):
     # A user should be able to specify an index column for return     
     result_frame = gbq._parse_data(FakeClient(), self.fake_job, index_col='word')
     correct_frame = DataFrame(self.correct_data_small)
     correct_frame.set_index('word', inplace=True)
     self.assertTrue(result_frame.index.name == correct_frame.index.name)