When passing DataFrame, dmatrices returns design matrix with zero rows using standardize in formula
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Reproduce both cases from the issue using pandas, numpy, and patsy.dmatrices with standardize(a). Start at the dmatrices and standardize entry points and trace how constant values and NaN values affect row handling. Done means the examples no longer produce a design matrix with zero rows, with behavior covered for both cases.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 990
- Forks
- 106
- Avg merge
- 7d 34m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pydata/patsy
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·