image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

wp = pd.read_csv('https://raw.githubusercontent.com/kunal-mallick/Kaggle-Project/Working/Water%20Quality(Drinking%20Water%20Potability)/src/main/resources/water_potability.csv')
wp

wp_nrow = wp.shape[0]

def lost_record():
    wp_nrow_now = wp.shape[0]
    lost = wp_nrow - wp_nrow_now
    lost = lost / wp_nrow * 100
    lost = round(lost, 2)
    return

def missing_percentage(wp):
    m = wp.isna().sum()
    total = int(wp.shape[0])
    for i in range(len(wp.columns)):
        percentage = round(m[i] / total * 100)

wp.fillna(value={'ph': wp['ph'].median(), 'Sulfate': wp['Sulfate'].median(), 'Trihalomethanes': wp['Trihalomethanes'].median()}, inplace=True)

wp[wp.duplicated()]

fig, ax = plt.subplots(3, 3, figsize = (15,8))

plt.setp(ax[0,0], title = 'PH')
sns.boxplot(wp['ph'], orient = 'h', ax = ax[0,0], color = '#ffadad')

plt.setp(ax[0,1], title = 'Hardness')
sns.boxplot(wp['Hardness'], orient = 'h', ax = ax[0,1], color = '#ffadad')

plt.setp(ax[0,2], title = 'Solids')
sns.boxplot(wp['Solids'], orient = 'h', ax = ax[0,2], color = '#ffadad')

plt.setp(ax[1,0], title = 'Chloramines')
sns.boxplot(wp['Chloramines'], orient = 'h', ax = ax[1,0], color = '#ffadad')

plt.setp(ax[1,1], title = 'Sulfate')
sns.boxplot(wp['Sulfate'], orient = 'h', ax = ax[1,1], color = '#ffd6a5')

plt.setp(ax[1,2], title = 'Conductivity')
sns.boxplot(wp['Conductivity'], orient = 'h', ax = ax[1,2], color = '#ffd6a5')

plt.setp(ax[2,0], title = 'Organic_carbon')
sns.boxplot(wp['Organic_carbon'], orient = 'h', ax = ax[2,0], color = '#ffadad')

plt.setp(ax[2,1], title = 'Trihalomethanes')
sns.boxplot(wp['Trihalomethanes'], orient = 'h', ax = ax[2,1], color = '#ffd6a5')

plt.setp(ax[2,2], title = 'Turbidity')
sns.boxplot(wp['Turbidity'], orient = 'h', ax = ax[2,2], color = '#fdffb6')

plt.tight_layout()

fig, ax = plt.subplots(3, 3, figsize=(15, 8))
plt.setp(ax[0, 0], title='PH')
sns.distplot(wp['ph'], ax=ax[0, 0], color='#e9ff70')
plt.setp(ax[0, 1], title='Hardness')
sns.distplot(wp['Hardness'], ax=ax[0, 1], color='#ffd670')
plt.setp(ax[0, 2], title='Solids')
sns.distplot(wp['Solids'], ax=ax[0, 2], color='#ff9770')
plt.setp(ax[1, 0], title='Chloramines')
sns.distplot(wp['Chloramines'], ax=ax[1, 0], color='#ffd670')
plt.setp(ax[1, 1], title='Sulfate')
sns.distplot(wp['Sulfate'], ax=ax[1, 1], color='#ffd670')
plt.setp(ax[1, 2], title='Conductivity')
sns.distplot(wp['Conductivity'], ax=ax[1, 2], color='#ff9770')
plt.setp(ax[2, 0], title='Organic_carbon')
sns.distplot(wp['Organic_carbon'], ax=ax[2, 0], color='#ff9770')
plt.setp(ax[2, 1], title='Trihalomethanes')
sns.distplot(wp['Trihalomethanes'], ax=ax[2, 1], color='#ff9770')
plt.setp(ax[2, 2], title='Turbidity')
sns.distplot(wp['Turbidity'], ax=ax[2, 2], color='#ff9770')
plt.tight_layout()