Filling missing values


I am trying to fill missing values of Dependents column using the below code and getting -

Sometimes getting
TypeError: (‘cannot use label indexing with a null key’) and KeyError

Code is -

print table
def combine(x):
return table.loc[x[‘Gender’],x[‘Dependents’]]


Hey @ASHISH_17,
The error here is that you are trying to access the table contents based on the Gender and Dependents value, where Dependents is actually Nan when the combine function is called.
So basically the return statement is being evaluated like this :


Hence the TypeError : cannot use label indexing with a null key.

Let me know if you did not quite get that,


What if I fill all the missing values?
I have tried using different columns where there is no null entry.
But this time I am getting KeyError
where I have used Self_Employed as index
KeyError: (‘Self_Employed’, u’occurred at index Loan_ID’)

How to proceed ?


Hey @ASHISH_17,
Impute the missing value on similar lines as discussed here : Imputing Missing Values

Hope that this helped,