turicreate.SFrame.add_column

SFrame.add_column(data, column_name='', inplace=False)

Returns an SFrame with a new column. The number of elements in the data given must match the length of every other column of the SFrame. If no name is given, a default name is chosen.

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:
data : SArray

The ‘column’ of data to add.

column_name : string, optional

The name of the column. If no name is given, a default name is chosen.

inplace : bool, optional. Defaults to False.

Whether the SFrame is modified in place.

Returns:
out : SFrame

The current SFrame.

See also

add_columns

Examples

>>> sf = turicreate.SFrame({'id': [1, 2, 3], 'val': ['A', 'B', 'C']})
>>> sa = turicreate.SArray(['cat', 'dog', 'fossa'])
>>> # This line is equivalent to `sf['species'] = sa`
>>> res = sf.add_column(sa, 'species')
>>> res
+----+-----+---------+
| id | val | species |
+----+-----+---------+
| 1  |  A  |   cat   |
| 2  |  B  |   dog   |
| 3  |  C  |  fossa  |
+----+-----+---------+
[3 rows x 3 columns]