text_plain_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df = pd.read_csv('../input/openintro-possum/possum.csv')
df

cat = ['sex', 'Pop', 'site']

fig,ax=plt.subplots(3, figsize=(10,10))
ax=ax.ravel()

for index, col in enumerate(cat):
    sns.boxplot(x='age',y=col,data=df, ax=ax[index])

df['site'] = df['site'].apply(lambda x: str(x))

fig,ax=plt.subplots(figsize=(15,15))
sns.heatmap(df.corr(),annot=True)
plt.show()
#to a limited degree, body dimensions are to some degree correlated with age

num = ['hdlngth',
 'skullw',
 'totlngth',
 'taill',
 'footlgth',
 'earconch',
 'eye',
 'chest',
 'belly']

#numerical columns EDA

fig,ax=plt.subplots(3,3, figsize=(10,10),constrained_layout=True)
ax=ax.ravel()

for index, col in enumerate(num):
    sns.histplot(x=col,data=df,ax=ax[index],
               kde=True)
    ax[index].set_title(f'Skewness:{df[col].skew(axis = 0)}')
    
#Some regression techniques don't work well skewed data, so we are doing this to detech is that's the case

num = ['hdlngth', 'skullw', 'totlngth', 'taill', 'footlgth', 'earconch', 'eye', 'chest', 'belly']
fig, ax = plt.subplots(3, 3, figsize=(10, 10), constrained_layout=True)
ax = ax.ravel()
for index, col in enumerate(num):
    log = f'{col}_log'
    df[log] = df[col].apply(lambda x: np.log(x + 1))
    sns.histplot(x=f'{col}_log', data=df, ax=ax[index], kde=True)
    ax[index].set_title(f'Skewness:{df[log].skew(axis=0)}')