text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

dataset = pd.read_csv('/kaggle/input/house-prices-advanced-regression-techniques/train.csv')

dataset.isnull().sum()

features_with_na = []
for features in dataset.columns:
    if dataset[features].isnull().sum() > 1:
        features_with_na.append(features)
features_with_na

features_with_na = [features for features in dataset.columns if dataset[features].isnull().sum() > 1]

for feature in features_with_na:
    data = dataset.copy()
    data[feature] = np.where(data[feature].isnull(), 1, 0)

numerical_features = [feature for feature in dataset.columns if dataset[feature].dtypes != 'O']

year_feature = [feature for feature in numerical_features if 'Yr' in feature or 'Year' in feature]
year_feature

for feature in year_feature:
    if feature != 'YrSold':
        data = dataset.copy()
        data[feature] = data['YrSold'] - data[feature]

discrete_feature = [feature for feature in numerical_features if len(dataset[feature].unique()) < 25 and feature not in year_feature + ['Id']]

discrete_feature