While handling with missing data for below columns from csv file it throws TypeError.How to resolve this ?
trainData.Gender.fillna(trainData.Gender.max(),inplace =True)
trainData.Married.fillna(trainData.Married.max(),inplace=True)
TypeError: '>=' not supported between instances of 'str' and 'float'
trainData.dtypes
Loan_ID object
Gender object
Married object
Dependents object
Education object
Self_Employed object
ApplicantIncome int64
CoapplicantIncome float64
LoanAmount float64
Loan_Amount_Term float64
Credit_History float64
Property_Area object
Loan_Status object
Doing it that way you are actually considering missing data(NaN, which are treated as floats) to look for the maximum value. So:
trainData.Gender.fillna(trainData.Gender.max(),inplace =True)
will try to compare str vs. floats.
You need to do:
trainData.Gender.fillna(trainData.Gender.dropna().max(),inplace =True)
trainData.Gender.fillna(trainData.Married.dropna().max(),inplace =True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With