From a885d118615bc56aa15fff3a6af9109fd3bd6bd9 Mon Sep 17 00:00:00 2001 From: matthewkrausse <106627640+mattkrausse@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:19:30 -0900 Subject: [PATCH] adding tests and docs to head and tail --- docs/table.rst | 4 ++++ test/test_etl.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/docs/table.rst b/docs/table.rst index 2c36e676bb..04a03c5cf9 100755 --- a/docs/table.rst +++ b/docs/table.rst @@ -156,6 +156,10 @@ of commonly used methods. The full list can be found in the API section. * - Method - Description + * - :py:meth:`~parsons.etl.etl.ETL.head` + - Get the first n rows of a table + * - :py:meth:`~parsons.etl.etl.ETL.tail` + - Get the last n rows of a table * - :py:meth:`~parsons.etl.etl.ETL.add_column` - Add a column * - :py:meth:`~parsons.etl.etl.ETL.remove_column` diff --git a/test/test_etl.py b/test/test_etl.py index 244781d1e7..ad9359ec24 100644 --- a/test/test_etl.py +++ b/test/test_etl.py @@ -997,3 +997,15 @@ def test_deduplicate(self): tbl_expected = Table([["a", "b", "c"], [1, 2, 3], [1, 3, 2], [2, 3, 4]]) tbl.deduplicate(["a", "b"]) assert_matching_tables(tbl_expected, tbl) + + def test_head(self): + tbl = Table([["a", "b"], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) + tbl_expected = Table([["a", "b"], [1, 2], [3, 4]]) + tbl.head(2) + assert_matching_tables(tbl_expected, tbl) + + def test_tail(self): + tbl = Table([["a", "b"], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) + tbl_expected = Table([["a", "b"], [7, 8], [9, 10]]) + tbl.tail(2) + assert_matching_tables(tbl_expected, tbl)