def test_table_remove(self): table = Table(headers=['python', 'rules']) table.extend([[1, 2], [3, 4], [5, 6], [1, 2]]) table.remove({'python': 3, 'rules': 4}) self.assertEquals(table[:], [[1, 2], [5, 6], [1, 2]]) table.remove([1, 2]) self.assertEquals(table[:], [[5, 6], [1, 2]])
def test_table_remove(self): table = Table(headers=["python", "rules"]) table.extend([[1, 2], [3, 4], [5, 6], [1, 2]]) table.remove({"python": 3, "rules": 4}) self.assertEquals(table[:], [[1, 2], [5, 6], [1, 2]]) table.remove([1, 2]) self.assertEquals(table[:], [[5, 6], [1, 2]])
table.insert(0, {"City": "La Paz", "State": "La Paz", "Country": "Bolivia"}) print "New table:" print table print table.reverse() print "And the table in the reversed order:" print table print popped_row = table.pop() rio = ["Rio de Janeiro", "Rio de Janeiro", "Brazil"] table.append(rio) # repeated row number_of_rios = table.count(rio) index_of_first_rio = table.index(rio) table.remove(rio) # remove the first occurrence of this row number_of_rows = len(table) print "Popped row:", popped_row print "Number of rows:", number_of_rows print "Count of Rios rows (before remove):", number_of_rios print "Table after pop and remove:" print table print # Removing non-brazilian cities: del table[:2] # Let's change an entire column: table["Country"] = ["Brasil", "Brasil", "Brasil"] print 'Column "Country" changed:' print table
table.insert(0, {'City': 'La Paz', 'State': 'La Paz', 'Country': 'Bolivia'}) print 'New table:' print table print table.reverse() print 'And the table in the reversed order:' print table print popped_row = table.pop() rio = ['Rio de Janeiro', 'Rio de Janeiro', 'Brazil'] table.append(rio) #repeated row number_of_rios = table.count(rio) index_of_first_rio = table.index(rio) table.remove(rio) #remove the first occurrence of this row number_of_rows = len(table) print 'Popped row:', popped_row print 'Number of rows:', number_of_rows print 'Count of Rios rows (before remove):', number_of_rios print 'Table after pop and remove:' print table print #Removing non-brazilian cities: del table[:2] #Let's change an entire column: table['Country'] = ['Brasil', 'Brasil', 'Brasil'] print 'Column "Country" changed:' print table