Skip to content
Advertisement

How to fix “only integers, slices (`:`), ellipsis (`…`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices” in this example

I have the following type of data.

InvoiceNo   InvoiceDate InvoiceType PriceType   SellManNo   CustomerNo  PaymentDate Total
91          1/15/2019   4           2           1           700         1/15/2019   1140.55
92          1/15/2019   4           2           1           13          1/15/2019   201
93          1/15/2019   4           2           1           675         1/15/2019   500
94          1/15/2019   4           2           1           456         1/15/2019   48
95          1/15/2019   4           2           1           709         1/15/2019   276
96          1/15/2019   4           2           1           98          2/14/2019   299
97          1/15/2019   1           2           1           1           1/15/2019   45.66
98          1/15/2019   4           2           1           478         1/15/2019   2.88

This is what I tried:

from sklearn.preprocessing import MinMaxScaler
scaling=MinMaxScaler()
df_total=df[['Total']]

df_total=scaling.fit_transform(df_total)

df_total

And I got the error.

only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Advertisement

Answer

All you should need is:

df['Total'] /= max(df['Total'])
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement