Skip to content

Commit

Permalink
Add cookbook for renaming columns. Closes wireservice#469.
Browse files Browse the repository at this point in the history
  • Loading branch information
nbedi committed Feb 15, 2016
1 parent 1c4e78a commit f39fba5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1.2.3
-----

* Cookbook: Rename columns in a table. (#469)
* :meth:`.Table.normalize` implemented. (#487)
* Added :class:`.Percent` computation with example in Cookbook. (#490)
* Added Ben Welsh to AUTHORS.
Expand Down
12 changes: 12 additions & 0 deletions docs/cookbook/misc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Miscellaneous
=============

Rename columns
===============

You can rename the columns in a table by using the :meth:`.Table.rename` method and specifying the new column names as an array or dictionary mapping old column names to new ones.

.. code-block:: python
table = Table(rows, column_names = ['a', 'b', 'c'])
new_table = table.rename(column_names = ['one', 'two', 'three'])
# or
new_table = table.rename(column_names = {'a': 'one', 'b': 'two', 'c': 'three'})
Reorder columns
===============

Expand Down

0 comments on commit f39fba5

Please sign in to comment.