0

My data:

absent_data.head()

My data

Before it was running smooth, this is my code:

cnames = ['Transportation expense', 'Distance from Residence to Work',
   'Service time', 'Age', 'Work load Average/day ', 'Hit target',
   'Son', 'Pet', 'Weight','Body mass index',
   'Absenteeism time in hours']

#Nomalization
for i in cnames:
    print(i)
    absent_data[i] = (absent_data[i] - min(absent_data[i]))/(max(absent_data[i]) - min(absent_data[i]))

Now getting this error:

TypeError Traceback (most recent call last) in () 2 for i in cnames: 3 print(i) ----> 4 absent_data[i] = (absent_data[i] - min(absent_data[i]))/(max(absent_data[i]) - min(absent_data[i]))

TypeError: 'numpy.float64' object is not callable

It was float before too.

HiMesh NaGar
  • 105
  • 2
  • 12

1 Answers1

1

I guess you are assigning a float value to min or max, and min or max function is overridden. Restart your notebook & remove the overriding part, then you would get the expected result.

Otherwise, just use sklearn.preprocessing.MinMaxScaler instead of implementing it by yourself.

Normalize columns of pandas data frame

Yuya Takashina
  • 592
  • 6
  • 13
  • The same code is working fine for another data set and there too I have float values. – HiMesh NaGar Mar 01 '19 at 08:14
  • 1
    Is there any line like `min = ...` or `max = ...` in your notebook? This will override the function and cause `is not callable` error. – Yuya Takashina Mar 01 '19 at 08:20
  • There was min=.. max=... in my notebook, that was after normalization code. That is the reason it worked well 1st time and after running the whole code again it was giving an error. Yes, I will do it using the sklearn library. Thank you so much. – HiMesh NaGar Mar 01 '19 at 08:44