I would like to read rows of data from .csv file and whenever i run my code it pops out this error. I have no idea how to solve this problem. I've looked up to some similar posts but still cant be solved.
Here is my code:
def getThreshold(dataSet, Attributes, isNumeric):
'''
Calculates median threshold from train dataset
'''
thresholds = []
for x in Attributes:
indx = Attributes.index(x)
numeric = isNumeric[indx]
if numeric:
listAtt = []
for row in dataSet:
listAtt.append(float(row[indx]))
# calculate median a numeric attribute column
median = statistics.median(listAtt)
thresholds.append(median)
return thresholds
Here is my sample data, (without quotes)
41,management,single,secondary,no,764,no,no,cellular,12,jun,230,2,-1,0,unknown,no
39,blue-collar,married,secondary,no,49,yes,no,cellular,14,may,566,1,370,2,failure,no
60,retired,married,primary,no,0,no,no,telephone,30,jul,130,3,-1,0,unknown,no
31,entrepreneur,single,tertiary,no,247,yes,yes,unknown,2,jun,273,1,-1,0,unknown,no
The problem is found in the first column which is the age, are identified as string. Is it the problem in csv file or code?