MCPcopy
hub / github.com/pandas-dev/pandas / fillna

Method fillna

pandas/core/generic.py:6922–7158  ·  view source on GitHub ↗

Fill NA/NaN values with `value`. Parameters ---------- 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

(
        self,
        value: Hashable | Mapping | Series | DataFrame,
        *,
        axis: Axis | None = None,
        inplace: bool = False,
        limit: int | None = None,
    )

Source from the content-addressed store, hash-verified

6920
6921 @final
6922 def fillna(
6923 self,
6924 value: Hashable | Mapping | Series | DataFrame,
6925 *,
6926 axis: Axis | None = None,
6927 inplace: bool = False,
6928 limit: int | None = None,
6929 ) -> Self:
6930 """
6931 Fill NA/NaN values with `value`.
6932
6933 Parameters
6934 ----------
6935 value : scalar, dict, Series, or DataFrame
6936 Value to use to fill holes (e.g. 0), alternately a
6937 dict/Series/DataFrame of values specifying which value to use for
6938 each index (for a Series) or column (for a DataFrame). Values not
6939 in the dict/Series/DataFrame will not be filled. This value cannot
6940 be a list.
6941 axis : {0 or 'index'} for Series, {0 or 'index', 1 or 'columns'} for DataFrame
6942 Axis along which to fill missing values. For `Series`
6943 this parameter is unused and defaults to 0.
6944 inplace : bool, default False
6945 If True, fill in-place. Note: this will modify any
6946 other views on this object (e.g., a no-copy slice for a column in a
6947 DataFrame).
6948 limit : int, default None
6949 This is the maximum number of entries along the entire axis
6950 where NaNs will be filled. Must be greater than 0 if not None.
6951
6952 Returns
6953 -------
6954 Series/DataFrame
6955 Object with missing values filled.
6956
6957 See Also
6958 --------
6959 ffill : Fill values by propagating the last valid observation to next valid.
6960 bfill : Fill values by using the next valid observation to fill the gap.
6961 interpolate : Fill NaN values using interpolation.
6962 reindex : Conform object to new index.
6963 asfreq : Convert TimeSeries to specified frequency.
6964
6965 Notes
6966 -----
6967 For non-object dtype, ``value=None`` will use the NA value of the dtype.
6968 See more details in the :ref:`Filling missing data<missing_data.fillna>`
6969 section.
6970
6971 Examples
6972 --------
6973 >>> df = pd.DataFrame(
6974 ... [
6975 ... [np.nan, 2, np.nan, 0],
6976 ... [3, 4, np.nan, 1],
6977 ... [np.nan, np.nan, np.nan, np.nan],
6978 ... [np.nan, 3, np.nan, 4],
6979 ... ],

Callers 15

time_fillnaMethod · 0.45
time_fillnaMethod · 0.45
time_fillnaMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45
_make_plotMethod · 0.45
__init__Method · 0.45
assert_index_equalFunction · 0.45
_flex_methodMethod · 0.45
_flex_arith_methodMethod · 0.45
_clip_with_one_boundMethod · 0.45
compareMethod · 0.45

Calls 15

_get_axis_numberMethod · 0.95
copyMethod · 0.95
reindexMethod · 0.95
_update_inplaceMethod · 0.95
itemsMethod · 0.95
whereMethod · 0.95
notnaMethod · 0.95
validate_bool_kwargFunction · 0.90
SeriesClass · 0.90
can_hold_elementFunction · 0.90
get_unique_dtypesMethod · 0.80
nonzeroMethod · 0.80

Tested by

no test coverage detected