I'm required to create a correlation matrix table using Tableau so I've created a version using Python to check if I did everything right.
The numbers are coming out different for both calculations. For example, correlation coefficient of Hotel 3 and 34 cross shows as 0.62 using python, but is 0.639 using Tableau.
Am I doing either calculation wrong? Please see this link for raw data, tableau workbook and pdf of plot created using python.
The code I used to create the correlation matrix is as follows:
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt %matplotlib inline data = pd.read_excel('Hotel Data.xlsx', engine='openpyxl') pivot = data.pivot_table(index=['Period','Slice'], columns='Hotel', values='Net Score Change', aggfunc=np.sum, fill_value=0) pivot.reset_index(inplace=True) sns.set(font_scale=0.5) plt.figure(figsize=(20,16)) sns.heatmap(pivot.corr(), cmap='coolwarm', annot=True)