import statistics
nums = [41, 65, 64, 50, 45, 13, 29, 14, 7, 14]
print(statistics.mean(nums))


###

import csv
f = open("all-icecream.csv")
data = list(csv.reader(f))
f.close()

counts = []
firstCol = data[0].index("#1 category")
for i in range(1, len(data)):
    line = data[i]
    categories = line[firstCol:firstCol + 3]
    count = categories.count("vanilla")
    counts.append(count)

print(statistics.mean(counts))

###

# prob that A is #2 given that B is #1
def getCondProb(data, flavorA, flavorB):
    flavorSubset = []
    firstCol = data[0].index("#1 category")
    for i in range(1, len(data)):
        line = data[i] # line is a list of strings
        if line[firstCol] == flavorB:
            flavorSubset.append(line[firstCol+1])
    count = flavorSubset.count(flavorA)
    return count / len(flavorSubset)

###

import matplotlib.pyplot as plt

x = [2, 4, 5, 7, 7, 9]
y = [3, 5, 4, 6, 9, 7]
plt.title("Product categories")
#plt.scatter(x, y)

labels = [ "A", "B", "C", "D", "E" ]
yValues = [ 10, 40, 36, 46, 21 ]
colors = [ "red", "yellow", "green", "blue", "purple" ]
# plt.bar(labels, yValues, color=colors)

firstCol = data[0].index("#1 cleaned")
numberOneFaves = []
flavors = []
for i in range(1, len(data)):
    flavor = data[i][firstCol]
    numberOneFaves.append(flavor)
    if flavor not in flavors:
        flavors.append(flavor)

counts = []
for flavor in flavors:
    counts.append(numberOneFaves.count(flavor))
    
plt.pie(counts, labels=flavors)
plt.show()