Python | Панды Series.valid ()
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Серия Pandas - это одномерный массив ndarray с метками осей. Этикетки не обязательно должны быть уникальными, но должны быть хешируемого типа. Объект поддерживает индексирование как на основе целых чисел, так и на основе меток и предоставляет множество методов для выполнения операций, связанных с индексом.
Pandas Series.valid() function return the same Series object but without the null values.
Syntax: Series.valid(inplace=False, **kwargs)
Parameter :
inplace: booleanReturns : Series
Example #1: Use Series.valid() function to remove the null values from the given Series object.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series(["New York", "Chicago", None, "Toronto", "Lisbon", "Rio", "Chicago", "Lisbon"]) # Print the seriesprint(sr) |
Выход :

Now we will use Series.valid() function to remove the null values from the given series object.
# return valid valuessr.valid() |
Выход :

As we can see in the output, the Series.valid() function has returned a Series object containing all the valid value of the original series object on which it was called.
Example #2: Use Series.valid() function to remove the null values from the given Series object.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series([100, 214, 325, 88, None, 325, None, 325, 100]) # Print the seriesprint(sr) |
Выход :

Now we will use Series.valid() function to remove the null values from the given series object.
# return valid valuessr.valid() |
Output :
As we can see in the output, the Series.valid() function has returned a Series object containing all the valid value of the original series object on which it was called.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.