turicreate.SFrame.swap_columns

SFrame.swap_columns(column_name_1, column_name_2, inplace=False)

Returns an SFrame with two column positions swapped.

If inplace == False (default) this operation does not modify the current SFrame, returning a new SFrame.

If inplace == True, this operation modifies the current SFrame, returning self.

Parameters:
column_name_1 : string

Name of column to swap

column_name_2 : string

Name of other column to swap

inplace : bool, optional. Defaults to False.

Whether the SFrame is modified in place.

Returns:
out : SFrame

The SFrame with swapped columns.

Examples

>>> sf = turicreate.SFrame({'id': [1, 2, 3], 'val': ['A', 'B', 'C']})
>>> res = sf.swap_columns('id', 'val')
>>> res
+-----+-----+
| val | id  |
+-----+-----+
|  A  |  1  |
|  B  |  2  |
|  C  |  3  |
+----+-----+
[3 rows x 2 columns]