def test_first_row_is_header_zero_rows(self):
     # TODO make fetch_result _not_ a pd.DataFrame
     fetch_result = ProcessResult(pd.DataFrame({'A': [], 'B': []}))
     result = scrapetable.render(pd.DataFrame(),
                                 P(first_row_is_header=True),
                                 fetch_result=fetch_result)
     assert_frame_equal(result, pd.DataFrame({'A': [], 'B': []}))
Beispiel #2
0
 def test_first_row_is_header_autocast_dtypes(self):
     # TODO make fetch_result _not_ a pd.DataFrame
     fetch_result = ProcessResult(pd.DataFrame({"A": ["nums", "3"]}))
     result = scrapetable.render(pd.DataFrame(),
                                 P(first_row_is_header=True),
                                 fetch_result=fetch_result)
     assert_frame_equal(result, pd.DataFrame({"nums": [3]}))
 def test_first_row_is_header(self):
     # TODO make fetch_result _not_ a pd.DataFrame, so we don't lose info
     # when converting types here
     fetch_result = ProcessResult(pd.DataFrame(a_table.copy()))
     result = scrapetable.render(pd.DataFrame(),
                                 P(first_row_is_header=True),
                                 fetch_result=fetch_result)
     assert_frame_equal(result, pd.DataFrame({'1': [2], '2': [3]}))
Beispiel #4
0
 def test_first_row_is_header_empty_values(self):
     # TODO make fetch_result _not_ a pd.DataFrame
     fetch_result = ProcessResult(
         pd.DataFrame({
             "A": ["", "x"],
             "B": [2, 3]
         }))
     result = scrapetable.render(pd.DataFrame(),
                                 P(first_row_is_header=True),
                                 fetch_result=fetch_result)
     assert_frame_equal(result, pd.DataFrame({"Column 1": ["x"], "2": [3]}))
 def test_first_row_is_header_empty_values(self):
     # TODO make fetch_result _not_ a pd.DataFrame
     fetch_result = ProcessResult(
         pd.DataFrame({
             'A': ['', 'x'],
             'B': [2, 3]
         }))
     result = scrapetable.render(pd.DataFrame(),
                                 P(first_row_is_header=True),
                                 fetch_result=fetch_result)
     assert_frame_equal(result, pd.DataFrame({
         'Column 1': ['x'],
         '2': [3],
     }))