Created
May 31, 2020 07:11
-
-
Save liusy182/2d20b752dd463b64301eb6b42d37479c to your computer and use it in GitHub Desktop.
missing values
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 numpy as np # linear algebra | |
| import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) | |
| # dataset: https://www.kaggle.com/camnugent/california-housing-prices | |
| df = pd.read_csv('/kaggle/input/california-housing-prices/housing.csv'); | |
| print('\nisnull before:\n', df['total_bedrooms'].isnull().any()) | |
| # isnull before: | |
| # True | |
| df['total_bedrooms'].fillna(df['total_bedrooms'].median(), inplace=True) | |
| print('\nisnull after:\n', df['total_bedrooms'].isnull().any()) | |
| # isnull after: | |
| # False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment