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.

9
  • what is absent_data? Commented Mar 1, 2019 at 7:38
  • @Ev.Kounis it is my dataset. Commented Mar 1, 2019 at 7:39
  • and what do you expect to happen when doing absent_data['Transportation expense'] for example? Because that is what you are doing.. Commented Mar 1, 2019 at 7:40
  • 1
    for i in cnames change it to for i in range(len(cnames)): Commented Mar 1, 2019 at 7:41
  • what is type(absent_data) Commented Mar 1, 2019 at 7:44

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

The same code is working fine for another data set and there too I have float values.
Is there any line like min = ... or max = ... in your notebook? This will override the function and cause is not callable error.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.