bigframes.pandas.DataFrame.fillna#
- DataFrame.fillna(value=None) DataFrame[source]#
Fill NA (NULL in BigQuery) values using the specified method.
Note that empty strings
'',numpy.inf, andnumpy.nanare *not* considered NA values. This NA/NULL logic differs from numpy, but it is the same as BigQuery and thepandas.ArrowDtype.Examples:
>>> df = bpd.DataFrame( ... [ ... pa.array([np.nan, 2, None, 0], type=pa.float64()), ... pa.array([3, np.nan, None, 1], type=pa.float64()), ... pa.array([None, None, np.nan, None], type=pa.float64()), ... pa.array([4, 5, None, np.nan], type=pa.float64()), ... ], columns=list("ABCD"), dtype=pd.ArrowDtype(pa.float64())) >>> df A B C D 0 NaN 2.0 <NA> 0.0 1 3.0 NaN <NA> 1.0 2 <NA> <NA> NaN <NA> 3 4.0 5.0 <NA> NaN [4 rows x 4 columns]
Replace all NA (NULL) elements with 0s.
>>> df.fillna(0) A B C D 0 NaN 2.0 0.0 0.0 1 3.0 NaN 0.0 1.0 2 0.0 0.0 NaN 0.0 3 4.0 5.0 0.0 NaN [4 rows x 4 columns]
You can use fill values from another DataFrame:
>>> df_fill = bpd.DataFrame(np.arange(12).reshape(3, 4), ... columns=['A', 'B', 'C', 'D']) >>> df_fill A B C D 0 0 1 2 3 1 4 5 6 7 2 8 9 10 11 [3 rows x 4 columns] >>> df.fillna(df_fill) A B C D 0 NaN 2.0 2.0 0.0 1 3.0 NaN 6.0 1.0 2 8.0 9.0 NaN 11.0 3 4.0 5.0 <NA> NaN [4 rows x 4 columns]
- Parameters:
value (scalar, Series) – Value to use to fill holes (e.g. 0), alternately a Series of values specifying which value to use for each index (for a Series) or column (for a DataFrame). Values not in the Series will not be filled. This value cannot be a list.
- Returns:
Object with missing values filled
- Return type: