这个问题与另一个问题非常相关,我甚至会在这个问题上使用非常有用的解决方案中的例子.以下是已接受的解决方案(信用证到unutbu)的示例:
import pandas as pd
import numpy as np
df = pd.DataFrame({'A': 'foo bar foo bar foo bar foo foo'.split(),
'B': 'one one two three two two one three'.split(),
'C': np.arange(8), 'D': np.arange(8) * 2})
print(df)
# A B C D
# 0 foo one 0 0
# 1 bar one 1 2
# 2 foo two 2 4
# 3 bar three 3 6
# 4 foo two 4 8
# 5 bar two 5 …Run Code Online (Sandbox Code Playgroud) 当我PyGUI-2.5.4.tar.gz从http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/下载并运行
pip install downloads/PyGUI-2.5.4.tar.gz
Run Code Online (Sandbox Code Playgroud)
我收到一个长错误,其根源似乎是以下内容:
tarfile.ReadError: not a gzip file
Run Code Online (Sandbox Code Playgroud)
有什么想法我做错了吗?
在 Python 的 中statsmodels.formula.api,ols 功能会自动包含并估计一个截距:
results = sm.ols(formula="s ~ x + y + z", data=somedata).fit()
results.params
(* Intercept 0.632646, x -1.258761, y 0.465076, z 0.497991 *)
Run Code Online (Sandbox Code Playgroud)
因为我在线性概率模型中使用它,有没有办法将截距固定为 0.5?