Correlation describes whether two measurements tend to move together. When both generally rise or fall together, the relationship is positive; when one tends to rise as the other falls, it is negative. A relationship can also be weak or strong. Correlation is an association measure, not proof that one measurement causes the other. section 11.12
In pandas, calculate numeric relationships with `corr()`. Calling it on a DataFrame returns a matrix: each column is compared with every other column, and each variable has a correlation of 1 with itself. A value of 0 indicates no correlation, 1 perfect alignment, and –1 complete opposition. section 11.12 section 13.3
high low high 1.000000 0.105603 low 0.105603 1.000000
A `corr()` result is symmetric: the high/low comparison appears in both off-diagonal cells, while the diagonal records self-correlation. section 11.12
Prepare comparable data before correlating
Correlation is most useful after the relevant numeric columns share the same observations. For oil price, ice-cream price, and miles driven, parse dates, use dates as indexes, join the three DataFrames, and retain only dates common to all of them. Then call `df.corr()` and inspect scatter plots for the oil–ice-cream and oil–miles relationships. Cleaning nonnumeric values and handling missing data are part of the analysis, not an afterthought. section 11.13 section 11.14
Use correlation as a compact follow-up to a concrete question:
- Compare a country’s mean wine score with its mean tourism spending after grouping and joining country-level results; inspect `NaN` values because join type changes which countries remain. section 7.13
- Compare the number of wines submitted by each country with that country’s mean score, after aggregating reviews by country. section 9.8
- Compare admission rate and tuition with `institutions_df[['ADM_RATE', 'TUITIONFEE_OUT']].corr()`, then use a scatter plot to check the overall pattern. section 13.3
A scatter plot complements the number. The tuition and admission-rate plot trends from top left toward bottom right, matching a reported correlation of –0.3: tuition tends to increase as admission rate tends to decrease, but only slightly. Plotting helps reveal the shape of an association rather than treating one value as a complete explanation. section 13.3















