pandas.SparseArray.fillna

SparseArray.fillna(value=None, method=None, limit=None)[source]

Fill missing values with value.

Parameters:
value : scalar, optional
method : str, optional

Warning

Using ‘method’ will result in high memory use, as all fill_value methods will be converted to an in-memory ndarray

limit : int, optional
Returns:
SparseArray

Notes

When value is specified, the result’s fill_value depends on self.fill_value. The goal is to maintain low-memory use.

If self.fill_value is NA, the result dtype will be SparseDtype(self.dtype, fill_value=value). This will preserve amount of memory used before and after filling.

When self.fill_value is not NA, the result dtype will be self.dtype. Again, this preserves the amount of memory used.

Scroll To Top