Adding ability to unique all rows in a dataset.

This commit is contained in:
Kevin Cherepski
2015-02-04 11:53:14 -05:00
parent 2fbda0f43d
commit dca7bc9a7d
2 changed files with 26 additions and 0 deletions
+7
View File
@@ -934,6 +934,13 @@ class Dataset(object):
return _dset
def unique(self):
"""Removes all duplicate rows from the :class:`Dataset` object
while maintaining the original order."""
seen = set()
self._data[:] = [row for row in self._data if not (tuple(row) in seen or seen.add(tuple(row)))]
def wipe(self):
"""Removes all content and headers from the :class:`Dataset` object."""
self._data = list()