"""Table VII: do the per-movie variables the authors keep 'from the first row' vary within a weekend?

Run from the package root:  python3 replication/check_weekend_vars.py data/movie.dta
"""
import sys
import pandas as pd

d = pd.read_stata(sys.argv[1], convert_categoricals=False)
d["weekend"] = d.opendate + 6 - d.openwday
d = d[d.pre != 1]
d["defl"] = d.grosscpi / d.gross
for v in ["fourday", "month", "openyr", "defl"]:
    nun = d.groupby("weekend")[v].nunique()
    print(f"{v}: weekends where it varies across movies = {(nun > 1).sum()}")
g = d.groupby("weekend").fourday.agg(["min", "max", "size"])
print(g[g["min"] != g["max"]])
