Standardize(x) comes before drop na

Open
#208 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
numpy, pandas, python
Domain
data

Research direction

Start by reproducing the two dmatrix examples from the issue and compare the handling of missing x2 values in drop_na and standardize(x2). Trace the standardize and missing-data processing entry points, then add a regression test showing the expected non-empty design matrix when standardization is used with missing data.

Written by the indexing model from the issue text.

Description

It looks like Standardize(x) comes before drop_na --> therefore the standardization returns all nan

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

df = pd.DataFrame({'x1': np.arange(5), 'x2': [1,2,np.nan,5,6]})

output:
dmatrix("~x1+x2", df)
[[1. 0. 1.]
[1. 1. 2.]
[1. 3. 5.]
[1. 4. 6.]]

dmatrix("~x1+standardize(x2)", df)
DesignMatrix with shape (0, 3)
Intercept x1 standardize(x2)
Terms:
'Intercept' (column 0)
'x1' (column 1)
'standardize(x2)' (column 2)

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

  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.