Last active
June 1, 2020 03:55
-
-
Save ChristopherDaigle/056cdb10602cfcff8c537b14ec4adc3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.impute import KNNImputer | |
imputer = KNNImputer(n_neighbors=int(round(np.sqrt(df_1.shape[0])))) | |
df_1.reset_index(inplace = True, drop = True) | |
impute_df = df_1.drop(columns='release_date') | |
impute_df_filled = imputer.fit_transform(X=impute_df) | |
imputed_cols = list(df_1.drop(columns='release_date').columns) | |
df_impute = pd.DataFrame(data=impute_df_filled, columns=imputed_cols) | |
df_1_impute_fill = pd.concat([df_impute, df_1['release_date']], axis=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment