Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

dmatrices raising “AssertionError”

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

Nobody has claimed this yet.

Assessment

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

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.

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?

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

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from pydata/patsy

All issues in pydata/patsy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.