我正在尝试运行泊松模型,如下所示:
poisson_model_xg = smf.glm(formula="xG ~ home + team + opponent", data=xg_model_data,
family=sm.families.Poisson()).fit()
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ValueError:endog 已计算为具有形状 (760, 9) 的多列数组。当转换为 endog 的变量是非数字(例如 bool 或 str)时,就会发生这种情况。
但我无法弄清楚这是什么意思,因为我所有的数据框都是数字:
xg_model_data.apply(lambda s: pd.to_numeric(s, errors='coerce').notnull().all())
Out[10]:
goals True
xG True
team True
opponent True
home True
dtype: bool
Run Code Online (Sandbox Code Playgroud)