Transforms like 'scale' need some way to handle missing data

未关闭
#82 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
pandas, python
领域
data

调研方向

该 issue 提供了一个可复现的 pandas DataFrame 和 pt.dmatrices 示例;首先运行 scale(X.diff()) 这一情况,并将其与 X.diff() 进行比较。跟踪变换产生的缺失值是如何处理的,并将完成定义为该表达式能够得到不导致崩溃的结果。

由索引模型根据 Issue 内容生成。

描述

In[92]: df = pd.DataFrame([(1,3),(2,6),(4,2),(6,5),(7,3),(4,6),(2,2),(6,4)], columns=['y','X'])
In[93]: pt.dmatrices('y ~ X.diff()', df)
Out[93]: 
(DesignMatrix with shape (7, 1)
   y
   2
   4
   6
   7
   4
   2
   6
   Terms:
     'y' (column 0),
 DesignMatrix with shape (7, 2)
   Intercept  X.diff()
           1         3
           1        -4
           1         3
           1        -2
           1         3
           1        -4
           1         2
   Terms:
     'Intercept' (column 0)
     'X.diff()' (column 1))

In[94]: pt.dmatrices('y ~ scale(X.diff())', df)

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\IPython\core\formatters.py", line 222, in catch_format_error
    r = method(self, *args, **kwargs)
  File "C:\Python34\lib\site-packages\IPython\core\formatters.py", line 699, in __call__
    printer.pretty(obj)
  File "C:\Python34\lib\site-packages\IPython\lib\pretty.py", line 368, in pretty
    return self.type_pprinters[cls](obj, self, cycle)
  File "C:\Python34\lib\site-packages\IPython\lib\pretty.py", line 552, in inner
    p.pretty(x)
  File "C:\Python34\lib\site-packages\IPython\lib\pretty.py", line 382, in pretty
    return meth(obj, self, cycle)
  File "C:\Python34\lib\site-packages\patsy\design_info.py", line 1089, in _repr_pretty_
    for col in formatted_cols]
  File "C:\Python34\lib\site-packages\patsy\design_info.py", line 1089, in <listcomp>
    for col in formatted_cols]
ValueError: max() arg is an empty sequence
Out[94]: 
主要语言
Python
星标
990
派生
113
平均合并
2 天 8 小时
30 天内合并 PR
3

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pydata/patsy 的其他 Issue

查看 pydata/patsy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。