i would like to create a correlation function between a column and the others, passing the dataframe with all columns, corelating wiht a specif colum and returning a list of metrics and correlation i`am doing this like this.
correlations = df.corr().unstack().sort_values(ascending=True)
correlations = pd.DataFrame(correlations).reset_index()
correlations.columns = ['corr_matrix', 'dfbase', 'correlation']
correlations.query("corr_matrix == 'venda por m2' & dfbase != 'venda por m2'")
but i would like to know a way to make this with a function.
Something like this should do