turicreate.SFrame.fillna

SFrame.fillna(column_name, value)

Fill all missing values with a given value in a given column. If the value is not the same type as the values in column_name, this method attempts to convert the value to the original column’s type. If this fails, an error is raised.

Parameters:
column_name : str

The name of the column to modify.

value : type convertible to SArray’s type

The value used to replace all missing values.

Returns:
out : SFrame

A new SFrame with the specified value in place of missing values.

See also

dropna

Examples

>>> sf = turicreate.SFrame({'a':[1, None, None],
...                       'b':['13.1', '17.2', None]})
>>> sf = sf.fillna('a', 0)
>>> sf
+---+------+
| a |  b   |
+---+------+
| 1 | 13.1 |
| 0 | 17.2 |
| 0 | None |
+---+------+
[3 rows x 2 columns]