# turicreate.SFrame.select_columns¶

SFrame.select_columns(column_names)

Selects all columns where the name of the column or the type of column is included in the column_names. An exception is raised if duplicate columns are selected i.e. sf.select_columns([‘a’,’a’]), or non-existent columns are selected.

Throws an exception for all other input types.

Parameters: column_names: list[str or type] The list of column names or a list of types. out : SFrame A new SFrame that is made up of the columns referred to in column_names from the current SFrame.

Examples

>>> sf = turicreate.SFrame({'user_id': [1,2,3],
...                       'user_name': ['alice', 'bob', 'charlie'],
...                       'zipcode': [98101, 98102, 98103]
...                      })
>>> # This line is equivalent to sf2 = sf[['user_id', 'zipcode']]
>>> sf2 = sf.select_columns(['user_id', 'zipcode'])
>>> sf2
+---------+---------+
| user_id | zipcode |
+---------+---------+
|    1    |  98101  |
|    2    |  98102  |
|    3    |  98103  |
+---------+---------+
[3 rows x 2 columns]