def get_canonical_correlations(dataframe, column_types):
def preprocess(series):<EOL><INDENT>if column_types[series.name] == '<STR_LIT>':<EOL><INDENT>series = pd.get_dummies(series)<EOL><DEDENT>array = series.values.reshape(series.shape[<NUM_LIT:0>], -<NUM_LIT:1>)<EOL>return array<EOL><DEDENT>if dataframe.shape[<NUM_LIT:1>] < <NUM_LIT:2>:<EOL><INDENT>return []<EOL><DEDENT>correlations = []<EOL>skip_cols = set()<EOL>for col_name_i, col_name_j in itertools.combinations(dataframe.columns, <NUM_LIT:2>):<EOL><INDENT>if col_name_i in skip_cols or col_name_j in skip_cols:<EOL><INDENT>correlations.append(<NUM_LIT:0>)<EOL>continue<EOL><DEDENT>df_ij = dataframe[[col_name_i, col_name_j]].dropna(axis=<NUM_LIT:0>, how="<STR_LIT>")<EOL>col_i = df_ij[col_name_i]<EOL>col_j = df_ij[col_name_j]<EOL>if np.unique(col_i).shape[<NUM_LIT:0>] <= <NUM_LIT:1>:<EOL><INDENT>skip_cols.add(col_name_i)<EOL>correlations.append(<NUM_LIT:0>)<EOL>continue<EOL><DEDENT>if np.unique(col_j).shape[<NUM_LIT:0>] <= <NUM_LIT:1>:<EOL><INDENT>skip_cols.add(col_name_j)<EOL>correlations.append(<NUM_LIT:0>)<EOL>continue<EOL><DEDENT>col_i = preprocess(col_i)<EOL>col_j = preprocess(col_j)<EOL>col_i_c, col_j_c = CCA(n_components=<NUM_LIT:1>).fit_transform(col_i,col_j)<EOL>if np.unique(col_i_c).shape[<NUM_LIT:0>] <= <NUM_LIT:1> or np.unique(col_j_c).shape[<NUM_LIT:0>] <= <NUM_LIT:1>:<EOL><INDENT>c = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>c = np.corrcoef(col_i_c.T, col_j_c.T)[<NUM_LIT:0>,<NUM_LIT:1>]<EOL><DEDENT>correlations.append(c)<EOL><DEDENT>return correlations<EOL>
computes the correlation coefficient between each distinct pairing of columns
preprocessing note:
    any rows with missing values (in either paired column) are dropped for that pairing
    categorical columns are replaced with one-hot encoded columns
    any columns which have only one distinct value (after dropping missing values) are skipped
returns a list of the pairwise canonical correlation coefficients