DataFrame.fillNa
Fill NaN/undefined values using the specified method. Detect missing values for an array-like object.
danfo.DataFrame.fillNa(values, options) [source]
Parameters
Type
Description
Default
values
Array | Scalar
The list of value(s) to use for replacement.
options
Object
{columns:Array of column name(s) to fill. If undefined fill all columns
inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false
}
{inplace: false}
Examples
Fill missing values in specified columns with specified values
Missing values are NaN, undefined or null values
const dfd = require("danfojs-node")
let data = {
"Name": ["Apples", "Mango", "Banana", undefined],
"Count": [NaN, 5, NaN, 10],
"Price": [200, 300, 40, 250]
}
let df = new dfd.DataFrame(data)
df.print()
let values = ["Apples", df["Count"].mean()]
let df_filled = df.fillNa(values, { columns: ["Name", "Count"] })
df_filled.print()Fill all columns with NaNs with a specified value
Fill NaNs inplace
Last updated
Was this helpful?