Python | Панды Series.quantile ()
Серия Pandas - это одномерный массив ndarray с метками осей. Этикетки не обязательно должны быть уникальными, но должны быть хешируемого типа. Объект поддерживает индексирование как на основе целых чисел, так и на основе меток и предоставляет множество методов для выполнения операций, связанных с индексом.
Pandas Series.quantile() function return value at the given quantile for the underlying data in the given Series object.
Syntax: Series.quantile(q=0.5, interpolation=’linear’)
Parameter :
q : float or array-like, default 0.5 (50% quantile)
interpolation : {‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}Returns : quantile : float or Series
Example #1: Use Series.quantile() function to return the desired quantile of the underlying data 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.quantile() function to find the 40% quantile of the underlying data in the given series object.
# return the value of 40 % quantileresult = sr.quantile(q = 0.4) # Print the resultprint(result) |
Выход :

As we can see in the output, the Series.quantile() function has successfully returned the desired qunatile value of the underlying data of the given Series object.
Example #2: Use Series.quantile() function to return the desired quantile of the underlying data in the given Series object.
Выход :

Now we will use Series.quantile() function to find the 90% quantile of the underlying data in the given series object.
# return the value of 90 % quantileresult = sr.quantile(q = 0.9) # Print the resultprint(result) |
Выход :

As we can see in the output, the Series.quantile() function has successfully returned the desired qunatile value of the underlying data of the given Series object.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.