Пример #1
0
 def test_render_range_clamp_range(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table, P(select_range=True, column_numbers="-1,2,6"))
     self.assertEqual(
         result,
         i18n_message(
             "badParam.column_numbers.invalid",
             {"value": "-1"},
         ))
Пример #2
0
 def test_render_range_ignore_empty_range(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table.copy(), P(select_range=True, column_numbers=""))
     self.assertEqual(
         result,
         i18n_message(
             "badParam.column_numbers.invalid",
             {"value": ""},
         ),
     )
Пример #3
0
 def test_render_range_non_numeric_ranges(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table,
                     P(select_range=True, column_numbers="2-3,giraffe"))
     self.assertEqual(
         result,
         i18n_message(
             "badParam.column_numbers.invalid",
             {"value": "giraffe"},
         ),
     )
Пример #4
0
 def test_render_range_overlapping_ranges(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table, P(select_range=True, column_numbers="2-3,2"))
     self.assertEqual(result,
                      i18n_message("badParam.column_numbers.overlapping"))
Пример #5
0
 def test_render_range_hyphen_separated(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table,
                     P(select_range=True, column_numbers="2-3", keep=False))
     assert_frame_equal(result, pd.DataFrame({"A": [1, 2]}))
Пример #6
0
 def test_render_range_comma_separated(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table, P(select_range=True, column_numbers="1,3"))
     assert_frame_equal(result, pd.DataFrame({"A": [1, 2], "C": [3, 4]}))
Пример #7
0
 def test_render_drop_columns(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table, P(["B", "C"], keep=False))
     assert_frame_equal(result, pd.DataFrame({"A": [1, 2]}))
Пример #8
0
 def test_render_maintain_input_column_order(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table, P(["B"], keep=False))
     assert_frame_equal(result, pd.DataFrame({"A": [1, 2], "C": [3, 4]}))
Пример #9
0
 def test_render_single_column(self):
     table = pd.DataFrame({"A": [1, 2], "B": [2, 3], "C": [3, 4]})
     result = render(table, P(["A"]))
     assert_frame_equal(result, pd.DataFrame({"A": [1, 2]}))