-2

Please Open the Image for the problem

All the problem is with Embarked Attribute. Whenever in onehotencoding() I remove column no 11, the fit_transform() works fine. But when I add the 11th column again, i get the Value error saying input contains NaN.

  • 1
    Please **re-read** [How to ask](https://stackoverflow.com/help/how-to-ask), as it would seem that you missed some crucial points the first time you read it, namely "***DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question*" (emphasis in the original). See why [an image of your code is not helpful](https://idownvotedbecau.se/imageofcode). – desertnaut Jun 09 '20 at 21:32

1 Answers1

0

ColumnTransformer does not apply its transformers sequentially, it does so in parallel. So the 11th column going into the Encoder doesn't do so after having been imputed, and OneHotEncoder fails on data with missing values.

You could use a Pipeline with steps Impute and Encode, and use that only for column 11 in the ColumnTransformer.

Ben Reiniger
  • 10,517
  • 3
  • 16
  • 29