Commit 639c397015760ba5463279a53c5ae2ab239913af
- Diff rendering mode:
- inline
- side by side
datamatrix/datamatrix.py
(28 / 12)
|   | |||
| 407 | 407 | ||
| 408 | 408 | self[colName] = colData | |
| 409 | 409 | ||
| 410 | def rename(self, oldColumn, newColumn): | ||
| 410 | 411 | ||
| 412 | "Renames a column." | ||
| 413 | |||
| 414 | if oldColumn not in self: | ||
| 415 | raise KeyError, unicode("Unknown column") | ||
| 416 | |||
| 417 | for index, column in enumerate(self.columns): | ||
| 418 | |||
| 419 | if oldColumn == column: | ||
| 420 | self.columns[index] = newColumn | ||
| 421 | |||
| 422 | self._records[newColumn] = self._records[oldColumn] | ||
| 423 | |||
| 424 | del self._records[oldColumn] | ||
| 425 | |||
| 426 | |||
| 411 | 427 | class EmptyMatrix(DataMatrix): | |
| 412 | 428 | ||
| 413 | """DataMatrix variant that once instantiated generates an | ||
| 414 | empty matrix with specified columns and row names. | ||
| 415 | Does not depend upon reading a file. | ||
| 416 | Rows and columns, after initialization, can be added with insertRows, | ||
| 417 | insert, appendRows and append methods, respectively.""" | ||
| 429 | """DataMatrix variant that once instantiated generates an | ||
| 430 | empty matrix with specified columns and row names. | ||
| 431 | Does not depend upon reading a file. | ||
| 432 | Rows and columns, after initialization, can be added with insertRows, | ||
| 433 | insert, appendRows and append methods, respectively.""" | ||
| 418 | 434 | ||
| 419 | def __init__(self, identifier = None, row_names = None, columns = None): | ||
| 435 | def __init__(self, identifier = None, row_names = None, columns = None): | ||
| 420 | 436 | ||
| 421 | self.rownames = row_names if row_names else list() | ||
| 422 | self._records = dict() | ||
| 423 | self.columns = list() if not columns else columns | ||
| 424 | self.identifier = identifier | ||
| 437 | self.rownames = row_names if row_names else list() | ||
| 438 | self._records = dict() | ||
| 439 | self.columns = list() if not columns else columns | ||
| 440 | self.identifier = identifier | ||
| 425 | 441 | ||
| 426 | for column in self.columns: | ||
| 427 | self._records[column] = list() | ||
| 442 | for column in self.columns: | ||
| 443 | self._records[column] = list() | ||
| 428 | 444 | ||
| 429 | 445 | ||
| 430 | 446 | def cbind(first_matrix, second_matrix): |

