I am trying to work on the below code:
ds = load_csv('C:\\User.csv')
f = open(ds,'r')
lines = f.readlines()[1:]
print(lines)
f.close()
First line of dataset is string. I am getting the below error:
TypeError: expected str, bytes or os.PathLike object, not list
Though when I try to open the file with below code it works:
filename='C:\\User.csv'
f = open(filename,'r')
lines = f.readlines()[1:]
print(lines)
f.close()
I am ignoring the first line because its string and rest of the dataset is float.
Update:
load_csv
def load_csv(ds):
    dataset = list()
    with open(ds, 'r') as file:
        csv_reader = reader(file)
        for row in csv_reader:
            if not row:
                continue
            dataset.append(row)
            return dataset
Even if I use this way still get the error:
ds = load_csv('C:\\Users.csv')
minmax = dataset_minmax(ds)
normalize_dataset(ds, minmax)
def dataset_minmax(dataset):
    minmax = list()
    for i in range(len(dataset[0])):
        col_values = [row[i] for row in dataset]
        value_min = min(col_values)
        value_max = max(col_values)
        minmax.append([value_min, value_max])
    return minmax
def normalize_dataset(dataset, minmax):
    for row in dataset:
        for i in range(len(row)):
            row[i] = (row[i] - minmax[i][0]) / (minmax[i][1] - minmax[i][0])
It gives error on:
row[i] = (row[i] - minmax[i][0]) / (minmax[i][1] - minmax[i][0])
Error:
TypeError: unsupported operand type(s) for -: 'str' and 'str'
 
     
     
    