Last active
October 17, 2017 21:41
-
-
Save doron2402/9e92cd07380da09ec6d65aee549922c2 to your computer and use it in GitHub Desktop.
filling missing value python
This file contains hidden or 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
import pandas as pd | |
import sklearn as sk | |
# import the dataset | |
dataset = pd.read_csv(‘db.csv’) | |
# Load all columns into matrix but not the last ones | |
x = dataset.iloc[0:12,0:5].values | |
# Last column from the dataset | |
y = dataset.iloc[0:12,6].values | |
# Use the mean for fill missing data | |
imputer = sk.preprocessing.Imputer() | |
imputer = imputer.fit(x[0:12,3:5]) | |
x[0:12,3:5] = imputer.transform(x[0:12,3:5]) | |
# now the missing value will be filled with the mean of the column |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment