pydata / pydata/patsy

dmatrices raising “AssertionError”

Open
#148 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
990
Forks
106
Avg merge
7d 34m
Merged PRs (30d)
1

Description

Totally inexperienced user. My first Negative Binomial Regression. iPython on Google's Colab. I load the dataset as a pandas df. The features (and Target) in the formula below all appear in the df (which I named "dataset").

I also bring in

from patsy import dmatrices
import statsmodels.api as sm

however, when I

formula = """Target ~ MeanAge   + %White + %HHsNotWater + HHsIneq*10    + %NotSaLang + %male + %Informal + COGTACatG2B09 + %Poor + AGRating  """
data = dataset

response, predictors = dmatrices(formula, data, return_type='dataframe')
nb_results = sm.GLM(response, predictors, family=sm.families.NegativeBinomial(alpha=0.15)).fit()
print(nb_results.summary())

I simply get "AssertionError: ", and an arrow to line four (the one starting "response"). I have no idea how to remedy this, and cannot figure out if why this happens. Is it a Patsy issue? a Colab issue? A daft coding issue? Any sage guidance, please?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the full traceback for the dmatrices(formula, data, return_type='dataframe') call and compare the formula terms with the dataset columns. Reproduce the assertion in the reported Colab or IPython setup using the shown formula and data, then document the minimal cause and a verified remedy.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, pandas, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.