1

Here I have a dataset with three inputs. Here I generated y value using append. After the append I got the output like this:

 y.append(rec.iloc[0]['y'])

enter image description here

Then I tried to develop neural network model with these values. Before that I tried to scale the y value. my code:

y =y.values().astype(int)
scaler_y = preprocessing.MinMaxScaler(feature_range =(0, 1))
y = np.array(y).reshape([-1, 1])
y = scaler_y.fit_transform(y)

Then I got an error :

AttributeError                            Traceback (most recent call last)
<ipython-input-254-2ec9d2fcbffd> in <module>()
----> 1 y = y.values().astype(int)

 AttributeError: 'list' object has no attribute 'values'

Can anyone help me to solve this error?

bala
  • 75
  • 1
  • 4
  • 10

1 Answers1

2

It is basically what the error message says. The problem is this:

y =y.values().astype(int)

y is a list and lists do not have a method values() (but dictionaries and DataFrames do).

If you would like to convert y to a list of integers you can use list comprehension:

y = [int(x) for x in y]

Or alternatively use map (but I'd prefer the list comprehension):

y = list(map(int, y))

Since this is actually a coding related question you might want to consider posting on https://stackoverflow.com next time.

Jonathan
  • 5,605
  • 1
  • 11
  • 23