text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/colorectal-cancer-patients/crc.txt', sep='\t')
df

df = df.drop('Unnamed: 9', axis=1)
df = df.drop('Unnamed: 10', axis=1)
df = df.drop('Unnamed: 11', axis=1)
df = df.drop(index=62, axis=0)
df

features_num = ['Age (in years)', 'DFS (in months)']

# plot distributions
for f in features_num:
    fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10,7))
    
    ax1.hist(df[f])
    ax1.grid()
    ax1.set_title('Histogram of ' + f)
    
    ax2.boxplot(df[f], vert=False)
    ax2.grid()   
    ax2.set_title('Boxplot of ' + f)
    
    plt.show()

# correlations
corr_pearson = df[features_num].corr(method='pearson')
corr_spearman = df[features_num].corr(method='spearman')

fig = plt.figure(figsize = (8,6))
sns.heatmap(corr_pearson, annot=True, cmap='RdYlGn', vmin=-1, vmax=+1)
plt.title('Pearson Correlation')
plt.show()

fig = plt.figure(figsize = (8,6))
sns.heatmap(corr_spearman, annot=True, cmap='RdYlGn', vmin=-1, vmax=+1)
plt.title('Spearman Correlation')
plt.show()

features_cat = ['Dukes Stage', 'Gender', 'Location', 'DFS event', 'Adj_Radio', 'Adj_Chem']

for f in features_cat:
    df[f].value_counts().sort_index().plot(kind='bar')
    plt.title(f)
    plt.grid()
    plt.show()