fillna() function do in data analysis?The fillna() function replaces missing values (NaN) in a dataset with a specified value or method.
fillna()?Calculate the mean of the column and pass it to fillna(). For example: df['col'].fillna(df['col'].mean())
fillna()?Filling with a constant replaces all missing values with the same value. Using method='ffill' fills missing values with the last known non-missing value above it.
fillna() be used to fill missing values in both Series and DataFrames?Yes, fillna() works on both pandas Series and DataFrames to fill missing values.
fillna() without assigning the result back to the DataFrame or using inplace=True?The original DataFrame remains unchanged because fillna() returns a new object by default unless inplace=True is set.
method='ffill' means forward fill, which copies the last valid value downwards to fill missing spots.
df['age'].fillna(df['age'].mean()) do?This replaces missing values in the 'age' column with the column's mean value.
fillna()?The value parameter specifies the constant to fill missing values with.
fillna() regarding modifying the original DataFrame?By default, fillna() returns a new object and does not change the original unless inplace=True is set.
fillna()?dropna() is a separate function and cannot be used inside fillna().
fillna() function.method='ffill' and filling with a constant value in fillna().