# Co-efficient and p-value
from scipy import stats
pearson_coef, p_val = stats.pearsonr(df["col1"], df["col2"])
# Visualize correlation
import seaborn as sns
sns.lmplot(x="col1", y="col2", data=df, ci=None)
plt.show()
# Find correlation among all columns in a dataframe
correlations = df.corr()
# Use heatmap for correlation visualization (Scatterplot is not a good choice for dataframes with more than 2 variables)
sns.heatmap(correlations, annot=True) # use cmap='coolwarm' to provide color map
# Bend x label ticks 45 degree to avoid overlappings with each-other
plt.xticks(rotation=45)
plt.title('Correlations')
plt.show()