1
$\begingroup$

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) 
$\endgroup$

1 Answer 1

1
$\begingroup$

Both are using the Pearson algorithm to calculate correlations: https://en.m.wikipedia.org/wiki/Pearson_correlation_coefficient

However, the floating values operations are slightly different and this slight difference becomes taller when you make several operations like Pearson.

You can try by calculating the Pearson algorithm manually for both cases.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.