Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When passing DataFrame, dmatrices returns design matrix with zero rows using standardize in formula #166

Open
rmwenzel opened this issue Jan 10, 2021 · 0 comments

Comments

@rmwenzel
Copy link

rmwenzel commented Jan 10, 2021

When passing a pandas.DataFrame, dmatrices is returning a design matrix with no rows in at least two cases I could find.

Here's some minimal examples.

Case 1: All column values are the same

import pandas as pd
from patsy import dmatrices

df = pd.DataFrame({'a': [1, 1, 1], 'b': [0, 1, 0]})
formula = 'b ~ standardize(a)'
dmatrices(formula, data=df)

give

DesignMatrix with shape (0, 2)
  Intercept  standardize(a)
  Terms:
    'Intercept' (column 0)
    'standardize(a)' (column 1)

Case 2. Column values are different but contain np.nan

import pandas as pd
import numpy as np
from patsy import dmatrices

df = pd.DataFrame({'a': [2, 3, np.nan], 'b': [0, 1, 0]})
formula = 'b ~ standardize(a)'
dmatrices(formula, data=df)

gives the same

DesignMatrix with shape (0, 2)
  Intercept  standardize(a)
  Terms:
    'Intercept' (column 0)
    'standardize(a)' (column 1)

patsy version is the latest on conda, 0.5.1

@rmwenzel rmwenzel changed the title When passing DataFrame, dmatrices returns design matrix with zero rows standardize in formula in several cases When passing DataFrame, dmatrices returns design matrix with zero rows using standardize in formula Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant