Misleading error when non-numeric inputs fed to SimpleImputer
- Dominant language
- Python
- Stars
- 951
- Forks
- 262
- PR merge metrics
- No merged PRs in 30d
Description
Currently, if a dataframe with non-numeric values is passed into the simple imputer and the strategy is mean or median, it will give an error like `ValueError: Length of passed values is 2, index implies 3`.
This is because the mean and quantile functions automatically exclude any non-numeric columns. If `numeric_only=False` gets passed to the mean and quantile functions, it would give a more straightforward error like `TypeError: could not convert string to float: 'xyz'` for mean, and `TypeError: can't multiply sequence by non-int of type 'float'` for median.
Contributor guide
Research direction
Start at the SimpleImputer implementation and trace the mean and median strategy paths for dataframe inputs containing non-numeric values. Reproduce the reported case, then verify that invalid inputs produce direct conversion errors rather than the misleading length/index error; no specific source file or test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100