Value Error: could not convert string to float:

时间:2019-03-19 15:03:55

标签: python

I want to call a function in order to load a dataset but I'm getting an error: ValueError: could not convert string to float:

Can someone help me please?

def loadMyDataset(path):
    my_data=[]
    f = open(path , "r")
    lines = f.readlines()

    for line in lines:
        line = line.strip()
        my_strings = line.split("\t")
        my_data.append([float(my_strings[0]),float(my_strings[1])])
    return my_data        

myDataFile = 'g-dss4.txt'
data_size=10

my_dataSet= loadMyDataset(myDataFile)
print("Συνολο δεδομενων:", my_dataSet)

0 个答案:

没有答案