mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
+3
-3
@@ -895,17 +895,17 @@ class Dataset(object):
|
||||
new_headers = [self.headers[0]] + self[self.headers[0]]
|
||||
|
||||
_dset.headers = new_headers
|
||||
for column in self.headers:
|
||||
for index, column in enumerate(self.headers):
|
||||
|
||||
if column == self.headers[0]:
|
||||
# It's in the headers, so skip it
|
||||
continue
|
||||
|
||||
# Adding the column name as now they're a regular column
|
||||
row_data = [column] + self[column]
|
||||
# Use `get_col(index)` in case there are repeated values
|
||||
row_data = [column] + self.get_col(index)
|
||||
row_data = Row(row_data)
|
||||
_dset.append(row=row_data)
|
||||
|
||||
return _dset
|
||||
|
||||
|
||||
|
||||
+9
-1
@@ -241,7 +241,6 @@ class TablibTestCase(unittest.TestCase):
|
||||
# Delete from invalid index
|
||||
self.assertRaises(IndexError, self.founders.__delitem__, 3)
|
||||
|
||||
|
||||
def test_csv_export(self):
|
||||
"""Verify exporting dataset object as CSV."""
|
||||
|
||||
@@ -738,6 +737,15 @@ class TablibTestCase(unittest.TestCase):
|
||||
self.assertEqual(second_row,
|
||||
("gpa",90, 67, 50))
|
||||
|
||||
def test_transpose_multiple_headers(self):
|
||||
|
||||
data = tablib.Dataset()
|
||||
data.headers = ("first_name", "last_name", "age")
|
||||
data.append(('John', 'Adams', 90))
|
||||
data.append(('George', 'Washington', 67))
|
||||
data.append(('John', 'Tyler', 71))
|
||||
self.assertEqual(data.transpose().transpose().dict, data.dict)
|
||||
|
||||
|
||||
def test_row_stacking(self):
|
||||
"""Row stacking."""
|
||||
|
||||
Reference in New Issue
Block a user