BaşlayınÜcretsiz Başlayın

Cross-selling products

The small grocery store has decided to cross-sell chewing gum with either coffee, cereal, or bread. To determine which of the three items is best to use, the store owner has performed an experiment. For one week, she sold chewing gum next to the register and recorded all transactions where it was purchased with either coffee, cereal, or bread. The transactions from that day are available as a list of lists named transactions. Each transaction is either ['coffee','gum'], ['cereal','gum'], or ['bread','gum'].

Bu egzersiz

Market Basket Analysis in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Count the number of transactions that contain coffee and gum.
  • Count the number of transactions that contain cereal and gum.
  • Count the number of transactions that contain bread and gum.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Count the number of transactions with coffee and gum
coffee = transactions.count(['____', 'gum'])

# Count the number of transactions with cereal and gum
cereal = transactions.____(['cereal', 'gum'])

# Count the number of transactions with bread and gum
bread = transactions.____(['____', '____'])

# Print the counts for each transaction.
print('coffee:', coffee)
print('cereal:', cereal)
print('bread:', bread)
Kodu Düzenle ve Çalıştır