referring to
pandas.DataFrame.isna() vs pandas.DataFrame.isnull(). Not to confuse with pandas.isnull(), which in contrast to the two above isn't a method of the DataFrame class.These two DataFrame methods do exactly the same thing! Even their docs are identical. You can even confirm this in pandas' code.
But why have two methods with different names do the same thing?
This is because pandas' DataFrames are based on R's DataFrames. In Rna and null are two separate things. Read this post for more information.However, in python, pandas is built on top of numpy, which has neither
na nor null values. Instead numpy has NaN values (which stands for "Not a Number"). Consequently, pandas also uses NaN values.In short
- To detect
NaNvalues numpy usesnp.isnan(). - To detect
NaNvalues pandas uses either.isna()or.isnull().
TheNaNvalues are inherited from the fact that pandas is built on top of numpy, while the two functions' names originate from R's DataFrames, whose structure and functionality pandas tried to mimic.
Geen opmerkingen:
Een reactie posten