पर्सेंटाइल सांख्यिकी में उपयोग किया जाने वाला एक शब्द है जो व्यक्त करता है कि एक स्कोर उसी सेट में अन्य स्कोर की तुलना में कैसा है। इस प्रोग्राम में, हमें Pandas सीरीज़ का nth पर्सेंटाइल ढूंढना है।
एल्गोरिदम
चरण 1: Pandas सीरीज़ परिभाषित करें। चरण 2: पर्सेंटाइल मान इनपुट करें। चरण 3: पर्सेंटाइल गणना करें। चरण 4: पर्सेंटाइल प्रिंट करें।
उदाहरण कोड
import pandas as pd
series = pd.Series([10, 20, 30, 40, 50])
print("Series:\n", series)
n = int(input("Enter the percentile you want to calculate: "))
n = n / 100
percentile = series.quantile(n)
print("The {} percentile of the given series is: {}".format(n * 100, percentile))
आउटपुट
Series: 0 10 1 20 2 30 3 40 4 50 dtype: int64 Enter the percentile you want to calculate: 50 The 50.0 percentile of the given series is: 30.0
व्याख्या
Pandas लाइब्रेरी में quantile फ़ंक्शन केवल 0 और 1 के बीच मान पैरामीटर के रूप में लेता है। इसलिए, हमें quantile फ़ंक्शन में पास करने से पहले पर्सेंटाइल मान को 100 से विभाजित करना होगा।