TransWikia.com

Is it ok to fill a pandas dataframe with NaN values?

Data Science Asked by Loretta on August 7, 2021

Is it correct to fill a pandas dataframe with NaN values? In specific: if I have a dataframe with a user name and his age is it ok to fill the age column with int and NaN values.

Names  Age 
Lisa   25
Jack   NaN
Tom    32

Later on I want to work with this dataframe, will I get any problems if I have NaN values in it?

One Answer

It depends on what problems you are afraid of:

  • regarding "technical" issues, it should be ok having NaNs in your dataframe and, afterwards, applying the pd.isna(column_name) per attribute to get a boolean mask to find those unknown values per column, more info here
  • in case your problem is not knowing the actual values, one option is imputation, but not all types of variables are easily imputable (neither it makes sense to impute all of them)

Correct answer by German C M on August 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP