The fillna operation allows you to replace missing or NaN values in your dataset with a specified value or method (such as forward-fill or backward-fill). This can be helpful when you need to clean up your data before performing further analysis.

Here's a brief explanation and examples of different methods to fill missing values using the Fill Na function:

Function

  • Replace: Replace missing values with a specific value.
  • Backfill: Replace missing values using the next valid value in the column or row.
  • Forwardfill: Replace missing values using the previous valid value in the column or row.
  • Interpolate: Replace missing values using linear interpolation based on existing values.
  • Most frequent: Replace missing values with the most frequent value in the column.
  • Mean: Replace missing values with the mean value of the column.
  • Median: Replace missing values with the median value of the column.
  • Max: Replace missing values with the maximum value of the column.
  • Min: Replace missing values with the minimum value of the column.

Example

Dataset:

AB
1NaN
24
3NaN

Fill NaN values with 0:

AB
10
24
30