I have created a function that sorts through a csv file and returns lists into tuples however the items in the lists are string, how do I convert them to floats?
I need to do calculations with this data such as mean, median etc.
def load_data(filename):
datasets = []
for line in open(filename):
line = line.strip().split(",")
dataset = ((line[0],line[1:]))
datasets.append(dataset)
return datasets
At the moment my data looks like this when printed ('Slow Loris', [' 21.72', ' 29.3', ' 20.08', ' 29.98',......
etc how do I remove the ' '
around the numbers