Saymayı kolaylaştırma

Python'da Veri Tipleri

Jason Myers

Instructor

Collections Modülü

  • Standart Kitaplık parçası
  • Gelişmiş veri kapları
Python'da Veri Tipleri

Counter

  • Veri sayımı ve frekans ölçümü için özel sözlük
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'da Veri Tipleri

En yaygınları bulmak için Counter

  • .most_common() yöntemi sayaç değerlerini azalan sırada döndürür
print(nyc_eatery_count_by_types.most_common(3))
[('Mobile Food Truck', 114), ('Food Cart', 74), ('Snack Bar', 24)]
Python'da Veri Tipleri

Hadi pratik yapalım!

Python'da Veri Tipleri

Preparing Video For Download...