Error In Fit_transform: Input Contains NaN, Infinity Or A Value Too Large For Dtype('float64')
I have a dataframe of shape (14407, 2564). I am trying to remove low variance features using the VarianceThreshold function. However, when I call fit_transform, I get the following
Solution 1:
I solved this by casting my data to numeric. It appears that, although the error message states 'float64', my data was all objects only and objects did not work well with fit_transform.
Changing my data to float using:
df = df.apply(lambda x: pd.to_numeric(x,errors='ignore'))
solved the issue.
Post a Comment for "Error In Fit_transform: Input Contains NaN, Infinity Or A Value Too Large For Dtype('float64')"