One-way ANOVA asks whether city means differ. Use ols + anova_lm on tiny rainfall groups.
Goal
Print the ANOVA table for mm by city.
import pandas as pd
import statsmodels.formula.api as smf
from statsmodels.stats.anova import anova_lm
df = pd.DataFrame({'city': ['Nairobi'] * 4 + ['Mombasa'] * 4 + ['Kisumu'] * 4, 'mm': [80, 60, 110, 90, 40, 20, 50, 35, 120, 90, 140, 100]})
fit = smf.ols('mm ~ C(city)', data=df).fit()
print(anova_lm(fit).round(4))import pandas as pd
print(pd.DataFrame({'city': ['Nairobi', 'Mombasa'], 'mm': [80, 40]}).groupby('city').mean())import pandas as pd
import statsmodels.formula.api as smf
df = pd.DataFrame({'g': ['A', 'A', 'B', 'B'], 'y': [1, 2, 8, 9]})
print(smf.ols('y ~ C(g)', data=df).fit().fvalue)import pandas as pd
print(pd.Series([80, 60, 110]).var(ddof=1))