首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python statsmodels.imputation.mice:形状不匹配

Python statsmodels.imputation.mice:形状不匹配
EN

Stack Overflow用户
提问于 2018-03-21 22:05:47
回答 1查看 1.3K关注 0票数 0

我尝试使用MICE module of statsmodels来估算我的数据集。然而,我总是在一些我不理解的维度上得到错误。

以下是可重现的代码:

代码语言:javascript
运行
复制
# Impute missing values using MICE
import random
import pandas as pd
import numpy as np
import statsmodels.imputation.mice as mice

df = pd.DataFrame(np.random.randn(50, 4), columns=list('ABCD'))
ix = [(row, col) for row in range(df.shape[0]) for col in range(df.shape[1])]
for row, col in random.sample(ix, int(round(.1*len(ix)))):
    df.iat[row, col] = np.nan

imp = mice.MICEData(df)
imp.update_all(10)

我得到的错误是:

代码语言:javascript
运行
复制
ValueError: shape mismatch: value array of shape (2,1) 
could not be broadcast to indexing result of shape (2,)
EN

回答 1

Stack Overflow用户

发布于 2018-03-22 05:02:55

我认为这是一个已知的错误:https://github.com/statsmodels/statsmodels/issues/4129看起来像是在他们的源代码库中修复了它,但还没有发布。您可以尝试获取它们的主分支并手动安装:http://www.statsmodels.org/dev/install.html

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49408522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档