Hi, I have a question regarding the code below for creating frequency table. My question is, why is the code def freq_table(column)
, because when I try to write it, I put def freq_table(genres)
instead. I think I understand the logic of frequency table, I just didn’t understand where is the argument (column) instead of (genres). Can somebody please elaborate the logic for me please? Greatly appreciate it.
Best,
Cho
def extract(index):
column = []
for row in apps_data[1:]:
value = row[index]
column.append(value)
return column
genres = extract(11)
SOLUTION CODE
def freq_table(column):
frequency_table = {}
for value in column:
if value in frequency_table:
frequency_table[value] += 1
else:
frequency_table[value] = 1
return frequency_table
genres_ft = freq_table(genres)