From 3eb44e8e571b4531bb534f409cfc407fca28ade4 Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Fri, 24 Aug 2012 09:56:59 +0200 Subject: [PATCH] added RenameCol and updated docs --- modules/base/pymod/table.py | 13 +++++++++++++ modules/doc/table.rst | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/base/pymod/table.py b/modules/base/pymod/table.py index 09e10f61a..e8735c3e3 100644 --- a/modules/base/pymod/table.py +++ b/modules/base/pymod/table.py @@ -275,6 +275,19 @@ class Table(object): ''' return self.name + def RenameCol(self, old_name, new_name): + """ + Rename column *old_name* to *new_name*. + + :param old_name: Name of the old column + :param new_name: Name of the new column + :raises: :exc:`ValueError` when *old_name* is not a valid column + """ + if old_name==new_name: + return + self.AddCol(new_name, self.col_types[self.GetColIndex(old_name)], + self[old_name]) + self.RemoveCol(old_name) def _Coerce(self, value, ty): ''' Try to convert values (e.g. from :class:`str` type) to the specified type diff --git a/modules/doc/table.rst b/modules/doc/table.rst index 73bc6cc79..f3af12770 100644 --- a/modules/doc/table.rst +++ b/modules/doc/table.rst @@ -59,6 +59,7 @@ Functions You Might be Interested In :meth:`~ost.table.Table.AddRow` add a row to the table :meth:`~ost.table.Table.AddCol` add a column to the table :meth:`~ost.table.Table.RemoveCol` remove a column from the table +:meth:`~ost.table.Table.RenameCol` rename a column :meth:`~ost.table.Table.Extend` append a table to the end of another table :meth:`~ost.table.Merge` merge two tables together :meth:`~ost.table.Table.Sort` sort table by column @@ -94,6 +95,8 @@ Functions You Might be Interested In :meth:`~ost.table.Table.PlotHistogram` Plot data as histogram :meth:`~ost.table.Table.PlotROC` Plot receiver operating characteristics (ROC) :meth:`~ost.table.Table.PlotEnrichment` Plot enrichment +:meth:`~ost.table.Table.PlotHexbin` Hexagonal density plot +:meth:`~ost.table.Table.PlotBar` Bar plot ============================================= ============================================ @@ -106,4 +109,4 @@ The Table class :members: :undoc-members: SUPPORTED_TYPES -.. autofunction:: ost.table.Merge \ No newline at end of file +.. autofunction:: ost.table.Merge -- GitLab