How to deal with missing values (NaN)?

How to deal with missing values (NaN)?

NaN refer to empty or there is no values that’s it

I know this but my question is more related to statistics.

  1. A Simple Option: Drop Columns with Missing Values . If your data is in a Data Frame called original data , you can drop columns with missing values
  2. A Better Option: Imputation. Imputation fills in the missing value with some number. …
  3. An Extension To Imputation.
2 Likes

df.dropna() if you want to eliminate the row entirely from analysis, df.fillna(df.mean()) if you would like to replace missing values with something like the mean and keep the rows for analysis

1 Like

you want to ask whether NAN will be treated as 0? For example , what happen if we sum the values? Or more importantly, what happen when we average the values because it takes into account for the divider. If you dont use np.nanmean as example, NAN will be take into account

1 Like
4 Likes

If this was indeed a data entry error, we can use one of the following approaches for dealing with the missing or faulty value:
to deal with NaN values:= chose one which suits your data

  1. Replace it with 0 .
  2. Repalce it with the average of the entire column
  3. Replace it with the average of the values on the previous & next date
  4. Discard the row entirely

Which approach you pick requires some context about the data and the problem.
hope this will help!!

3 Likes

Thanks, @lakshaysethia

Have you thought about replacing this value by a value taking from google statistics?