total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4
total_bill tip
0 16.99 1.01
1 10.34 1.66
2 21.01 3.50
3 23.68 3.31
4 24.59 3.61
total_bill tip
total_bill 1.000000 0.675734
tip 0.675734 1.000000
Firstly, it prints the head of the “tips” dataset. We can see the dataset contains various data like total_bill, tip, sex, smoker, day, time, and size. We are interested in total_bill and tip only. So, we are creating another DataFrame “data” that has two columns, total_bill, and tip. And then, we are printing the head of the data.
After that, we are using the DataFrane.corr() function to calculate the correlation matrix of total_bill and tip variables.
From the output correlation matrix, we can see that the correlation coefficient of total_bill and tip is 0.675734. It means that the total bill amount and the tip amount are positively related. If we increase the total bill amount, the tip amount also increases. And the number 0.675734 indicates that the correlation is quite strong.








































0 Comments