Repository: pri22296/beautifultable

Issue:
Add a filter method to get rows satisfying a certain condition
A filter method will be handy for certain use cases which returns a table with only those rows which satisfies a certain condition.

Discussion:

Patch:
diff --git a/.travis.yml b/.travis.yml
index a460ffb..e910083 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -37,7 +37,6 @@ script:
 
 deploy:
   provider: pypi
-  skip_existing: true
   distributions: sdist bdist_wheel
   user: pri22296
   password:
@@ -45,3 +44,5 @@ deploy:
   on:
     tags: true
     repo: pri22296/beautifultable
+    branch: master
+    python: '3.6'
diff --git a/beautifultable/beautifultable.py b/beautifultable/beautifultable.py
index 264f223..ea105de 100644
--- a/beautifultable/beautifultable.py
+++ b/beautifultable/beautifultable.py
@@ -816,6 +816,21 @@ class BeautifulTable(object):
         """
         return self[:]
 
+    def filter(self, key):
+        """Return a copy of the table with only those rows which satisfy a
+        certain condition.
+
+        Returns
+        -------
+        BeautifulTable:
+            Filtered copy of the BeautifulTable instance.
+        """
+        new_table = self.copy()
+        new_table.clear()
+        for row in filter(key, self):
+            new_table.append_row(row)
+        return new_table
+
     def get_column_header(self, index):
         """Get header of a column from it's index.
 


Test patch:
diff --git a/test.py b/test.py
index e8f3b0c..5db0698 100644
--- a/test.py
+++ b/test.py
@@ -23,6 +23,17 @@ class TableOperationsTestCase(unittest.TestCase):
         for item1, item2 in zip(iterable1, iterable2):
             self.assertEqual(item1, item2)
 
+    def test_filter(self):
+        new_table = self.table.filter(lambda x: x["rank"] > 1)
+        self.assertEqual(len(self.table), 5)
+        rows = [
+            ["Ethan", 2, "boy"],
+            ["Sophia", 2, "girl"],
+            ["Michael", 3, "boy"],
+        ]
+        for row_t, row in zip(new_table, rows):
+            self.compare_iterable(row_t, row)
+
     # Tests for column operations
 
     def test_column_count(self):