text_html_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

url = '../input/dataquest2020/energy_train.csv'
df_training = pd.read_csv(url)

url = '../input/dataquest2020/energy_test.csv'
df_testing = pd.read_csv(url)

df_training['source'] = 'train'
df_testing['source'] = 'test'

df = pd.concat([df_training, df_testing], axis=0, ignore_index=True)
df

df.isnull().sum().sort_values(ascending=False)

df.apply(lambda x: len(x.unique()))

corr = df.corr().round(2)
corr

mean_deg_c1 = df.groupby('SSM').mean()['degree_C1']
mean_deg_c1

miss_bool = df['degree_C1'].isnull()
df.loc[miss_bool, 'degree_C1'] = df.loc[miss_bool, 'SSM'].apply(lambda x: mean_deg_c1[x])
df['degree_C1'].isnull().sum()

mean_deg_c3 = df.groupby('SSM').mean()['degree_C3']
mean_deg_c3

miss_bool = df['degree_C3'].isnull()
df.loc[miss_bool, 'degree_C3'] = df.loc[miss_bool, 'SSM'].apply(lambda x: mean_deg_c3[x])
df['degree_C3'].isnull().sum()

mean_moisture_9 = df.groupby('SSM').mean()['moisture_9']
mean_moisture_9