My Code:
def freq_table(dataset, index):
frequency_table = {}
for row in dataset:
if row[index] in frequency_table:
frequency_table[row[index]] += 1
else:
frequency_table[row[index]] = 1
for key in frequency_table:
frequency_table[key] /= len(dataset)
for key in frequency_table:
frequency_table[key] *= 100
return frequency_table
freq_table(apple_data_final, 11)```
What I expected to happen:
What actually happened: So this is what i came up with for the function freq_table(). Its alot different to whats in the solution. I cant see anything wrong with mine except i have one extra for loop. Just curious if this solution is valid.
So this is what i came up with for the function freq_table(). Its alot different to whats in the solution. I cant see anything wrong with mine except i have one extra for loop. Just curious if this solution is valid.
<!--Enter other details below: -->