Lara Haase
Lara Haase

Reputation: 55

TypeError when using MICE algorithm from Fancy Impute in Python

I'm trying to fill missing data in my dataset and my mentor recommended I used the Fancy Impute package in Python, and specifically the MICE algorithm. First of all, as I read about MICE, it's very clear that it's a poor option if my missing data is NOT random (which I doubt since it seems like missing data is more likely to be in specific countries/years). So does anyone recommend a different algorithm? (My project is based on the World Bank Gender Statistics data).

The technical problem: I ran this code on my dataframe:

filled = MICE().complete(dfvars)

But I got this error, and my mentor has no idea what it's about, and I haven't found any other forums discussing MICE in python at all:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Upvotes: 0

Views: 956

Answers (1)

Sarthak
Sarthak

Reputation: 21

The error is encountered because MICE is used to impute numeric data only, if the dataset contains categorical data but you wish to impute numeric data you should use just the numeric columns of the dataframe. If categorical data is missing then a different algorithm would have to be used.

Upvotes: 2

Related Questions