Back
Guides›Event Impact Analysis›Twelve days at the Minnesota State Fair
USA

Twelve days at the Minnesota State Fair

This example shows how to run event impact analysis for a multi-day event a city or county has to staff, clean up after, and report on. The Minnesota State Fair ran 21 August through 1 September 2025: twelve days ending Labor Day, one of the largest state fairs in the country. The baseline is the same twelve weekdays two weeks before, 7 through 18 August.

Daily visits are visitation_usa_places.area_foot_traffic_day, the area model on these places. The district is the streets next to the grounds, plus downtown St. Paul hotels and restaurants. Grand Avenue is the control: a St. Paul commercial street far enough that this fair is not what you expect to move it.

A city report can use the twelve days as one period. The series result is the median of the twelve daily ratios. Both are below.

For this we use our US Places metrics, queried from Python. The helper below is all the setup the example needs:

import os
from datetime import date, timedelta

import numpy as np
import pandas as pd
import requests

API = "https://api.pine59.com/v3/datasets"
HEADERS = {"Authorization": f"Bearer {os.environ['PINE59_API_KEY']}"}

def run_query(dataset, body):
    rows, token = [], ""
    while True:
        r = requests.post(
            f"{API}/{dataset}:runQuery",
            json={**body, "pageToken": token},
            headers=HEADERS,
        )
        r.raise_for_status()
        payload = r.json()
        rows += [rec["fields"] for rec in payload.get("records", [])]
        token = payload.get("nextPageToken", "")
        if not token:
            return rows

def search_values(dataset, field, term):
    r = requests.post(
        f"{API}/{dataset}:searchFieldValues",
        json={"field": {"name": field}, "term": term},
        headers=HEADERS,
    )
    r.raise_for_status()
    return r.json().get("values", [])

def daterange(start, end):
    days = []
    cur = date.fromisoformat(start)
    last = date.fromisoformat(end)
    while cur <= last:
        days.append(cur.isoformat())
        cur += timedelta(days=1)
    return days

# Twelve fair days, Thursday through the following Monday.
EVENT_DAYS = daterange("2025-08-21", "2025-09-01")
# The same weekdays two weeks earlier.
BASELINE_DAYS = daterange("2025-08-07", "2025-08-18")
DATES = EVENT_DAYS + BASELINE_DAYS

1. The named building on the twelve days

Find a building on the grounds, then pull daily visits for every event day and every baseline day. location_id is the Placekey. The catalog lists vendors at 1265 Snelling Ave N and other buildings on the campus, not one polygon for the whole grounds. Warner Coliseum is the named building: zzy-227@5s8-ckw-rx5.

for name in search_values("visitation_usa_places.places", "location_name", "Warner Coliseum"):
    print(name)

FAIR = "zzy-227@5s8-ckw-rx5"
coliseum = run_query("visitation_usa_places.places", {
    "fields": [
        {"name": "location_id"},
        {"name": "location_name"},
        {"name": "street_address"},
        {"name": "city"},
        {"name": "latitude"},
        {"name": "longitude"},
    ],
    "filters": [{"fieldName": "location_id", "operator": "==", "value": FAIR}],
})[0]
fair_lat, fair_lon = float(coliseum["latitude"]), float(coliseum["longitude"])
print(coliseum["location_name"], coliseum["street_address"], FAIR)

def daily(ids):
    ids = list(dict.fromkeys(ids))
    rows = []
    for i in range(0, len(ids), 150):
        rows += run_query("visitation_usa_places.area_foot_traffic_day", {
            "fields": [
                {"name": "location_id"},
                {"name": "observation_start_date"},
                {"name": "visits_sum"},
            ],
            "filters": [
                {"fieldName": "location_id", "operator": "in", "values": ids[i:i + 150]},
                {"fieldName": "observation_start_date", "operator": "in", "values": DATES},
            ],
            "pageSize": 10000,
        })
    df = pd.DataFrame(rows)
    if df.empty:
        return df
    df["visits"] = df["visits_sum"].astype(float)
    return df

def period_index(wide, event_days, base_days):
    """Places with visits in both windows. Total index, and median of daily ratios."""
    if wide.empty:
        return {"places": 0, "event": 0, "baseline": 0, "index": np.nan, "median_day": np.nan}
    event = wide.reindex(columns=event_days).sum(axis=1)
    base = wide.reindex(columns=base_days).sum(axis=1)
    keep = wide.loc[(event > 0) & (base > 0)]
    if keep.empty:
        return {"places": 0, "event": 0, "baseline": 0, "index": np.nan, "median_day": np.nan}
    e = keep.reindex(columns=event_days).sum(axis=1)
    b = keep.reindex(columns=base_days).sum(axis=1)
    daily = []
    for ev, ba in zip(event_days, base_days):
        if ev in keep.columns and ba in keep.columns:
            num, den = keep[ev].sum(), keep[ba].sum()
            if den > 0:
                daily.append(num / den)
    return {
        "places": int(len(keep)),
        "event": float(e.sum()),
        "baseline": float(b.sum()),
        "index": float(e.sum() / b.sum()),
        "median_day": float(np.median(daily)) if daily else np.nan,
    }

arena = daily([FAIR]).pivot(
    index="location_id", columns="observation_start_date", values="visits"
)
print(period_index(arena, EVENT_DAYS, BASELINE_DAYS))
7–18 Aug (baseline)21 Aug–1 Sep (event)IndexMedian day
Warner Coliseum1,514483,224319350

How to read it: index is the twelve event days added up, divided by the twelve baseline days. That is the number a board report can print as one period. median_day is the median of the twelve daily ratios, each fair day against the same weekday two weeks before. A Friday against a Friday. Use that when one peak day should not carry the week.

The coliseum index is large because visits in the baseline window are low. A city already knows the building filled up during the fair. The streets, downtown hotels, and the control are the comparison that is not obvious from the calendar.

2. Adjacent streets, downtown, and the control

The district can be a few blocks, a radius, or a short list of streets, places, brands, or categories. Here it is three boxes of about the same idea: Snelling and Larpenteur next to the grounds, downtown St. Paul hotels and restaurants, and Grand Avenue as the control. Places whose centroid sits on the campus stay out of the Snelling strip, so vendors on the grounds are not counted as the adjacent streets. The category indexes use every matching place in each box. A place with visits in only one of the two twelve-day windows stays out.

CATEGORIES = {
    "Drinking Places (Alcoholic Beverages)": "bars",
    "Full-Service Restaurants": "restaurants",
    "Limited-Service Restaurants": "restaurants",
    "Snack and Nonalcoholic Beverage Bars": "restaurants",
    "Hotels (except Casino Hotels) and Motels": "hotels",
    "Gasoline Stations": "convenience",
    "Convenience Stores": "convenience",
}
RETAIL = [
    "Clothing Stores",
    "Shoe Stores",
    "Sporting Goods, Hobby, and Musical Instrument Stores",
    "Department Stores",
    "General Merchandise Stores, including Warehouse Clubs and Supercenters",
    "Grocery Stores",
    "Health and Personal Care Stores",
    "Beer, Wine, and Liquor Stores",
    "Electronics and Appliance Stores",
    "Used Merchandise Stores",
    "Office Supplies, Stationery, and Gift Stores",
]
# Snelling / Larpenteur next to the grounds, downtown St. Paul, Grand Avenue.
SNELLING = {"lon": (-93.172, -93.162), "lat": (44.968, 44.995)}
DOWNTOWN = {"lon": (-93.105, -93.085), "lat": (44.940, 44.955)}
GRAND = {"lon": (-93.155, -93.125), "lat": (44.936, 44.943)}
# Campus west of Snelling Ave N. Drop these from the adjacent-street box.
GROUNDS = {"lon": (-93.181, -93.167), "lat": (44.976, 44.991)}

places = pd.DataFrame(run_query("visitation_usa_places.places", {
    "fields": [
        {"name": "location_id"},
        {"name": "location_name"},
        {"name": "brands"},
        {"name": "top_category"},
        {"name": "sub_category"},
        {"name": "latitude"},
        {"name": "longitude"},
        {"name": "street_address"},
        {"name": "city"},
    ],
    "filters": [
        {"fieldName": "sub_category", "operator": "in", "values": list(CATEGORIES)},
        {"fieldName": "top_category", "operator": "in", "values": RETAIL},
        {"fieldName": "region", "operator": "==", "value": "MN"},
        {"fieldName": "city", "operator": "in",
         "values": ["Falcon Heights", "Saint Paul", "St Paul"]},
    ],
    "filterLogic": "($0 OR $1) AND $2 AND $3",
    "pageSize": 10000,
})).astype({"latitude": float, "longitude": float})
places = places[places.location_id != FAIR].copy()
places["group"] = places.sub_category.map(CATEGORIES)
places.loc[places.group.isna() & places.top_category.isin(RETAIL), "group"] = "retail"
places = places.dropna(subset=["group"])

def in_box(df, box):
    return df[df.longitude.between(*box["lon"]) & df.latitude.between(*box["lat"])]

campus = in_box(places, GROUNDS)
snelling = in_box(places, SNELLING)
snelling = snelling[~snelling.location_id.isin(campus.location_id)]
downtown = in_box(places, DOWNTOWN)
grand = in_box(places, GRAND)
print("Snelling / Larpenteur", snelling.group.value_counts().to_dict())
print("Downtown St. Paul", downtown.group.value_counts().to_dict())
print("Grand Avenue", grand.group.value_counts().to_dict())

day = daily(pd.concat([snelling, downtown, grand]).location_id.unique())

def wide_for(members):
    sub = day[day.location_id.isin(members.location_id)] if not day.empty else day
    if sub.empty:
        return pd.DataFrame()
    return sub.pivot(index="location_id", columns="observation_start_date", values="visits")

def category_index(members):
    rows = []
    for group, ids in members.groupby("group").location_id:
        part = day[day.location_id.isin(set(ids))] if not day.empty else day
        wide = part.pivot(index="location_id", columns="observation_start_date", values="visits") if not part.empty else pd.DataFrame()
        stats = period_index(wide, EVENT_DAYS, BASELINE_DAYS)
        stats["group"] = group
        rows.append(stats)
    return pd.DataFrame(rows).set_index("group")

print("Snelling / Larpenteur")
print(category_index(snelling).round(2))
print("Downtown St. Paul")
print(category_index(downtown).round(2))
print("Grand Avenue")
print(category_index(grand).round(2))

Put the three boxes next to each other. Snelling restaurants, for example, go from 8,509 visits in the baseline window to 33,770 in the event window (4.0); retail from 7,196 to 46,899 (6.5). Downtown hotels go from 143,219 to 125,369 (0.88), restaurants from 621,753 to 527,946 (0.85). On Grand Avenue, restaurants go from 100,819 to 99,084 (0.98) and retail from 81,102 to 86,492 (1.07). That is not one street moving and the rest of the city standing still; each box and each category has its own index.

The three boxes, every matching place with visits in both windows:

Places7–18 Aug (baseline)21 Aug–1 Sep (event)Index
Snelling / Larpenteur1418,57087,1624.7
Downtown St. Paul1521,124,780987,7660.88
Grand Avenue83188,845191,3721.01

Snelling / Larpenteur, the streets next to the grounds:

CategoryPlacesBaselineEventIndex
Retail57,19646,8996.5
Restaurants78,50933,7704.0
Bars12,0264,6562.3
Hotels18391,8362.2

Downtown St. Paul:

CategoryPlacesBaselineEventIndex
Bars22134,377126,1250.94
Retail29197,176183,7860.93
Hotels14143,219125,3690.88
Convenience628,25524,5400.87
Restaurants81621,753527,9460.85

Grand Avenue:

CategoryPlacesBaselineEventIndex
Retail3581,10286,4921.07
Restaurants46100,81999,0840.98
Bars26,9245,7970.84

How to read it: put the coliseum (319) beside Snelling (4.7) beside downtown (0.88) beside Grand Avenue (1.01). Snelling is well above 1 in every category in this box. Downtown is below 1 in every category. Grand Avenue is near 1 as a total, with retail a little above and bars below. Rank inside the category: a restaurant against other restaurants, a hotel against other hotels. Snelling bars and hotels are one place each; treat those two rows as thin.

The total and the median day count the same places: a place with visits in both twelve-day windows. A store that is open or closed in only one of the two periods stays out. Its visits would otherwise land on only one side of the ratio.

Datasets used

Area Foot Traffic Day
Reference data
Places
Reference data
Did you find what you were looking for?