`build._eval_factor` error condition attempts to access attribute `dtype` on `DataFrame` object, but no such attribute exists

オープン
#232 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
pandas, python
領域
data

調査の方向性

build._eval_factor から始め、数値因子エラーを、数値ではないデータを含む pandas DataFrame で再現します。既存のエラーパスを追跡し、二次的な属性エラーを発生させずに返されたデータ型を報告することを確認します。関連するテストスイートを実行して動作を確認します。

索引モデルが issue の本文から書いたものです。

説明

In _eval_factor we have:

    # Returns either a 2d ndarray, or a DataFrame, plus is_NA mask
    if factor_info.type == "numerical":
        result = atleast_2d_column_default(result, preserve_pandas=True)

followed by

        if not safe_issubdtype(np.asarray(result).dtype, np.number):
            raise PatsyError(
                "when evaluating numeric factor %s, "
                "I got non-numeric data of type '%s'" % (factor.name(), result.dtype),
                factor,
            )

When result is a pandas.DataFrame but the factor is not actually a safe numeric type, this code will try to raise an error, but in doing so it attempts to access result.dtype which does not exist.

This is not a critical bug; it just results in some pretty confusing error messages.

主要言語
Python
スター
990
フォーク
106
平均マージ
7日 34分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pydata/patsy のほかの issue

pydata/patsy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。