0
我想创建一个小程序,它允许我使用Python中的raw_input
(现在只是输入)函数将一组数字输入到OLS函数中如何使用输入或raw_input创建输入到OLS程序
目前,我有代码看起来像这样
import pandas as pd
from pandas import DataFrame
from pandas.stats.api import ols
inp=raw_input("Enter String A")
A=map(int,inp.split())
inp=raw_input("Enter String B")
B=map(int,inp.split())
inp=raw_input("Enter String C")
C=map(int,inp.split())
def firstreg():
df = pd.DataFrame({'A':[A], 'B':[B], 'C':[C]})
reg = ols (y=df['A'], x=df[['B','C']])
print reg
firstreg()
正如你看到的我是想用A=map(int,inp.split())
来解决我的问题。它没有工作。我也用A=array(inp)
和A=float(inp)
和A=str(inp)
尝试和解决我的问题都无济于事。主要问题是OLS函数是Pandas需要输入的字符串才能工作。
我想有这样的程序运行:
运行该文件regression.py
它要求输入字符串一个
- 用户输入他们的一组数字或者作为“1,2,3等...”或者“1 2 3等...”
- 然后用户对做同样的处理Enter String B和输入字符串C。
- 然后该程序打印出基于该OLS模型回归结果中
def firstreg():
我希望这个问题是有道理的。