pandas.Series.fillna¶
Fill NA/NaN values using the specified method.
- param value
- scalar, dict, Series, or DataFrame
Value to use to fill holes (e.g. 0), alternately a dict/Series/DataFrame of values specifying which value to use for each index (for a Series) or column (for a DataFrame). Values not in the dict/Series/DataFrame will not be filled. This value cannot be a list.
- param method
- {‘backfill’, ‘bfill’, ‘pad’, ‘ffill’, None}, default None
Method to use for filling holes in reindexed Series pad / ffill: propagate last valid observation forward to next valid backfill / bfill: use next valid observation to fill gap.
- param axis
- {0 or ‘index’}
Axis along which to fill missing values.
- param inplace
- bool, default False
If True, fill in-place. Note: this will modify any other views on this object (e.g., a no-copy slice for a column in a DataFrame).
- param limit
- int, default None
If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled. Must be greater than 0 if not None.
- param downcast
- dict, default is None
A dict of item->dtype of what to downcast if possible, or the string ‘infer’ which will try to downcast to an appropriate equal type (e.g. float64 to int64 if possible).
- return
Series Object with missing values filled.
Limitations¶
Parameters
method
,limit
anddowncast
are currently unsupported by Intel Scalable Dataframe Compiler.Parameter
inplace
is supported as literal value only.
Examples¶
import numpy as np
import pandas as pd
from numba import njit
@njit
def series_fillna():
s = pd.Series([4, np.nan, 2, 1])
return s.fillna(0)
print(series_fillna())
$ python ./series/series_fillna.py
0 4.0
1 0.0
2 2.0
3 1.0
dtype: float64
See also
Fill NaN values using interpolation.
Conform object to new index.
Convert TimeSeries to specified frequency.