काउंटिंग आसान बनाएँ

Python में डेटा टाइप्स

Jason Myers

Instructor

Collections मॉड्यूल

  • स्टैंडर्ड लाइब्रेरी का हिस्सा
  • एडवांस्ड डेटा कंटेनर
Python में डेटा टाइप्स

Counter

  • काउंटिंग और फ़्रीक्वेंसी मापने के लिए विशेष डिक्शनरी
from collections import Counter

nyc_eatery_count_by_types = Counter(nyc_eatery_types)
print(nyc_eatery_count_by_type)
Counter({'Mobile Food Truck': 114, 'Food Cart': 74, 'Snack Bar': 24,
'Specialty Cart': 18, 'Restaurant': 15, 'Fruit & Vegetable Cart': 4})
print(nyc_eatery_count_by_types['Restaurant'])
15
Python में डेटा टाइप्स

सबसे कॉमन खोजने के लिए Counter

  • .most_common() मेथड काउंटर वैल्यूज़ को अवरोही क्रम में देता है
print(nyc_eatery_count_by_types.most_common(3))
[('Mobile Food Truck', 114), ('Food Cart', 74), ('Snack Bar', 24)]
Python में डेटा टाइप्स

अभ्यास करते हैं!

Python में डेटा टाइप्स

Preparing Video For Download...