-
Book Overview & Buying
-
Table Of Contents
Python in Excel for Data Analytics
By :
Analysis of Variance (ANOVA) provides a single test of whether at least one group mean differs from the others. Instead of running multiple pairwise comparisons, it asks a broader question: is the variation between groups large enough, relative to the variation within groups, to suggest the groups are not all the same?
The result is summarized by an F-statistic, which compares between-group variability to within-group variability. If all groups truly have the same mean, this ratio should be close to 1. Larger values indicate stronger evidence that at least one group mean differs.
We already have two groups. We just need to create the third with the following code:
usa = mpg_df[mpg_df['origin'] == 'usa']['mpg']
Now run the test:
f_stat, p_value = stats.f_oneway(usa, europe, japan)
pd.DataFrame({
'F-statistic': [round(f_stat, 2)],
'p-value': [str(round...