Python | Pandas Index.notnull ()
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas Index.notnull() function detect existing (non-missing) values. This function return a boolean same-sized object indicating if the values are not NA. Non-missing values get mapped to True. Characters such as empty strings ” or numpy.inf are not considered NA values (unless you set pandas.options.mode.use_inf_as_na = True). NA values, such as None or numpy.NaN, get mapped to False values.
Syntax: Index.notnull()
Returns : Boolean array to indicate which entries are not NA.
Example #1: Use Index.notnull()() function to detect missing values in the given Index.
# importing pandas as pdimport pandas as pd # Creating the indexidx = pd.Index(["Jan", "", "Mar", None, "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]) # Print the Indexidx |
Выход :
Let’s find out all the non-missing values in the Index
# to find the non-missing values.idx.notnull() |
Выход :
As we can see in the output, all the non-missing values has been mapped to True and all the missing values has been mapped to False. Notice the empty string has been mapped to True as an empty string is not considered to be a missing value.
Example #2: Use Index.notnull() function find out all the non-missing values in the Index.
# importing pandas as pdimport pandas as pd # Creating the indexidx = pd.Index([22, 14, 8, 56, None, 21, None, 23]) # Print the Indexidx |
Выход :
Let’s find out all the non-missing values in the Index
# to find the non-missing values.idx.notnull() |
Выход :
As we can see in the output, all the non-missing values have been mapped to True and all the missing values have been mapped to False.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.