Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).

### v0.15.5
* Fixes multiple bugs with the `Table#remove`.

### v0.15.4
* Fixes bug with grouping tables with np.float64('nan') type objects.

Expand Down
3 changes: 2 additions & 1 deletion datascience/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,15 @@ def relabel(self, column_label, new_label):

def remove(self, row_or_row_indices):
"""Removes a row or multiple rows of a table in place."""
if not row_or_row_indices:
if not row_or_row_indices and not isinstance(row_or_row_indices, int):
return
if isinstance(row_or_row_indices, int):
rows_remove = [row_or_row_indices]
else:
rows_remove = row_or_row_indices
for col in self._columns:
self._columns[col] = [elem for i, elem in enumerate(self[col]) if i not in rows_remove]
self._num_rows -= len(rows_remove)
return self


Expand Down
2 changes: 1 addition & 1 deletion datascience/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.15.4'
__version__ = '0.15.5'
14 changes: 14 additions & 0 deletions tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,20 @@ def test_remove_single(table):
z | 1 | 10
""")

def test_remove_zeroth_row(table):
table.remove(0)
assert_equal(table, """
letter | count | points
b | 3 | 2
c | 3 | 2
z | 1 | 10
""")

def test_remove_num_rows(table):
num_rows_before = table.num_rows
table.remove(0)
assert table.num_rows + 1 == num_rows_before


##########
# Create #
Expand Down