Permalink
Browse files

Add rows() method.

  • Loading branch information...
1 parent 31deb0c commit 4b2d5799a9f3af93b8327758c06f5c6890bc5a1a @eseraygun committed Dec 2, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 table.py
View
@@ -62,6 +62,17 @@ def column(self, columnName):
"""
return self.matrix[:, self.columnIndices[columnName]]
+ def rows(self):
+ """
+ Returns a list of dicts.
+ """
+ rows = []
+ for rowName in self.rowNames:
+ row = {columnName: self[rowName, columnName] for columnName in self.columnNames}
+ row["_"] = rowName
+ rows.append(row)
+ return rows
+
def __getRowIndex(self, rowName):
if rowName is None:
return None

0 comments on commit 4b2d579

Please sign in to comment.