text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

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

def create_mean_std_df(df):
    means = df.mean()
    stds = df.std()
    ret_df = pd.concat([means, stds], axis=1).reset_index()
    ret_df.columns = ['index', 'mean', 'std']
    ret_df['pref'] = ret_df['index'].apply(lambda x: x.split('-')[0])
    ret_df['post'] = ret_df['index'].apply(lambda x: x.split('-')[1])
    return ret_df

def scatter(y, x=None, color= None):
    fig, ax = plt.subplots()
    un_c = color.unique()
    for i, col in enumerate(un_c):
        y_i = y[color == col]
        if type(x) != pd.core.series.Series:
            x_i = range(0 + i * (y.shape[0] - y_i.shape[0]),
                    (1 - i)*y_i.shape[0] + i * y.shape[0])
        else:
            x_i = x[color == col]
        ax.scatter(x_i, y_i, c=col, label=col,
               alpha=0.3)
        ax.set_ylabel(y.name)
        ax.legend()
        ax.grid(True)
    plt.show()

tr = create_mean_std_df(train_features.iloc[:, 4:])

scatter(y=tr['std'], x=tr['mean'], color=tr['pref'])