diff options
| author | Kenneth Reitz <me@kennethreitz.org> | 2016-02-07 06:38:58 -0500 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.org> | 2016-02-07 06:38:58 -0500 |
| commit | 995eabad37c827d34539500630c710ccf510d7c1 (patch) | |
| tree | 49994dfcb8dfbfceee7c277b297d4b6f9aaa0683 /tablib/core.py | |
| parent | d90358bf6991ec19a4c6a07173f9127e970d96fb (diff) | |
| parent | dca7bc9a7d637cfa6f0f00eaebe8bd0cb4e2d7cd (diff) | |
| download | tablib-995eabad37c827d34539500630c710ccf510d7c1.tar.gz | |
Merge pull request #182 from cherepski/develop
Adding ability to unique all rows in a dataset.
Diffstat (limited to 'tablib/core.py')
| -rw-r--r-- | tablib/core.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tablib/core.py b/tablib/core.py index 8c4cc51..e15206e 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -940,6 +940,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() |
