Python | Панды Series.notna ()
Серия Pandas - это одномерный массив ndarray с метками осей. Этикетки не обязательно должны быть уникальными, но должны быть хешируемого типа. Объект поддерживает индексирование как на основе целых чисел, так и на основе меток и предоставляет множество методов для выполнения операций, связанных с индексом.
Pandas Series.notna() function Detect existing (non-missing) values. This function return a boolean object having the size same as the object, indicating if the values are missing values or not. Non-missing values get mapped to True. Characters such as empty strings ” or numpy.inf are not considered NA values (unless pandas.options.mode.use_inf_as_na = True is set). NA values, such as None or numpy.NaN, get mapped to False values.
Syntax: Series.notna()
Parameter : None
Returns : Series
Example #1: Use Series.notna() function to detect all the non-missing values in the given series object.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series([10, 25, 3, 11, 24, 6]) # Create the Indexindex_ = ["Coca Cola", "Sprite", "Coke", "Fanta", "Dew", "ThumbsUp"] # set the indexsr.index = index_ # Print the seriesprint(sr) |
Выход :

Now we will use Series.notna() function to detect the non-missing values in the series object.
# detect non-missing valueresult = sr.notna() # Print the resultprint(result) |
Выход :

As we can see in the output, the Series.notna() function has returned a boolean object. True indicates that the corresponding value is not missing. False value indicates that the value is missing. All the values are True in this series as there is no missing values.
Example #2: Use Series.notna() function to detect all the non-missing values in the given series object.
Выход :

Now we will use Series.notna() function to detect the non-missing values in the series object.
# detect non-missing valueresult = sr.notna() # Print the resultprint(result) |
Выход :

As we can see in the output, the Series.notna() function has returned a boolean object. True indicates that the corresponding value is not missing. False value indicates that the value is missing.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.