小编Sha*_*ank的帖子

如何使用Statsmodels.api获得回归拦截

我正在尝试使用python库计算回归输出,但我无法使用;当我使用库时获取拦截值:

import statsmodels.api as sm
Run Code Online (Sandbox Code Playgroud)

它打印除截距之外的所有回归分析.

但是当我使用时:

from pandas.stats.api import ols
Run Code Online (Sandbox Code Playgroud)

我的熊猫代码:

Regression = ols(y= Sorted_Data3['net_realization_rate'],x = Sorted_Data3[['Cohort_2','Cohort_3']])
print Regression  
Run Code Online (Sandbox Code Playgroud)

我得到了拦截,并警告说这个librabry将来会被弃用,所以我试图使用Statsmodels.

我在使用pandas.stats.api时得到的警告:

警告(来自警告模块):文件"C:\ Python27\lib\idlelib\run.py",第325行exec代码在self.locals中FutureWarning:pandas.stats.ols模块已弃用,将在以后的版本中删除.我们引用像statsmodels这样的外部包,请参阅这里的一些示例:http://statsmodels.sourceforge.net/stable/regression.html

我的Statsmodels代码:

import pandas as pd
import numpy as np
from pandas.stats.api import ols
import statsmodels.api as sm

Data1 = pd.read_csv('C:\Shank\Regression.csv')  #Importing CSV
print Data1
Run Code Online (Sandbox Code Playgroud)

运行一些清洁代码

sm_model = sm.OLS(Sorted_Data3['net_realization_rate'],Sorted_Data3[['Cohort_2','Cohort_3']])
results = sm_model.fit()
print '\n'
print results.summary()
Run Code Online (Sandbox Code Playgroud)

我甚至尝试过statsmodels.formula.api:as:

sm_model = sm.OLS(formula ="net_realization_rate ~ Cohort_2 + Cohort_3", data = Sorted_Data3)
results = sm_model.fit()
print '\n'
print result.params …
Run Code Online (Sandbox Code Playgroud)

python pandas statsmodels

11
推荐指数
2
解决办法
1万
查看次数

VBA中空字符串的条件

如何检查vba中的字符串变量是否为空?

如果:

Dim StrFile1 As String, StrFile2 As String
Dim Text3 As String
Dim Len1 as Integer, Len2 As Integer 

  With NewMail
   Text3 = Cells(i, 3).Value
   StrPath = Cells(i, 2).Value & Text3
   Text = Cells(i, 1).Value

  .Subject = 
  ' adds the data in column3 with space as subject
  .From = 
  .To = Text
  .BCC = ""
  .TextBody = 

StrFile1 = Dir(StrPath & "*.txt")
   Len1 = Len(StrFile1)
   Do While Len(StrFile1) > 0
   .AddAttachment StrPath & StrFile1
   StrFile1 = Dir
   Loop

   StrFile2 …
Run Code Online (Sandbox Code Playgroud)

excel vba

4
推荐指数
1
解决办法
1万
查看次数

无法安装Statsmodels ... python

我使用32位cmd,64位窗口,python 2.7

当我输入命令pip install statsmodels时

我得到了scipy的一些模块的以下错误...

Failed building wheel for Scipy Failed cleaning build dir for scipy
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

python pip scipy python-2.7 statsmodels

4
推荐指数
3
解决办法
2万
查看次数

标签 统计

python ×2

statsmodels ×2

excel ×1

pandas ×1

pip ×1

python-2.7 ×1

scipy ×1

vba ×1