Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is python's equivalent of R's NA?

What is python's equivalent of R's NA?

To be more specific: R has NaN, NA, NULL, Inf and -Inf. NA is generally used when there is missing data. What is python's equivalent?

How libraries such as numpy and pandas handle missing values?

How does scikit-learn handle missing values?

Is it different for python 2.7 and python 3?

like image 499
power Avatar asked Feb 22 '15 03:02

power


People also ask

Is Na in R equivalent in Python?

What is python's equivalent of R's NA? To be more specific: R has NaN, NA, NULL, Inf and -Inf. NA is generally used when there is missing data.

What are NA values in Python?

None: None is a Python singleton object that is often used for missing data in Python code. NaN : NaN (an acronym for Not a Number), is a special floating-point value recognized by all systems that use the standard IEEE floating-point representation.

Is Na a number in Python?

NaN stands for Not A Number and is one of the common ways to represent the missing value in the data. It is a special floating-point value and cannot be converted to any other type than float. NaN value is one of the major problems in Data Analysis.

How does Python handle NaN values?

If there is a certain row with missing data, then you can delete the entire row with all the features in that row. axis=1 is used to drop the column with `NaN` values. axis=0 is used to drop the row with `NaN` values. In this case, see that we are able to achieve better accuracy than before.


1 Answers

nan in numpy is handled well with many functions:

>>> import numpy as np >>> a = [1, np.nan, 2, 3] >>> np.nanmean(a) 2.0 >>> np.nansum(a) 6.0 >>> np.isnan(a) array([False,  True, False, False], dtype=bool) 
like image 54
N1B4 Avatar answered Sep 29 '22 11:09

N1B4