Wondering why def freq_table(data_set,index):

Just wondering why in this instance we are using def freq_table(data_set,index)? We only have 1 argument we need to make I thought?
I understand why you would use it (example if you have a multiplication function you wrote e.g. multiple(x,y))

If you pass two parameters(dataset, index), you can use the function for any dataset and any column of that dataset.
If you want to use for only one specific dataset, you can use for any column of that dataset.
And for this purpose, you can use def freq_table(index), only index parameter.
So, using two parameters(dataset and index) instead of one parameter(index) increases your function’s reusability . Functions are made for reusability function.
@ hills.mike91
Hope it helps you.

1 Like

So it’s getting us in good practice to be able to use different datasets then?

Yeah just you have to made any dataset in the form of list of lists then you can use your function.

image

my code can use any csv file and a column index as input and then return frequency table dictionary.
You can try it.

1 Like