Skip to content

Commit

Permalink
Use isnull from pandas objects to capture pd.NA too
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelosthege committed Jan 26, 2021
1 parent f0f8d83 commit 6d5c78a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pymc3/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,10 +1695,10 @@ def pandas_to_array(data):
XXX: When `data` is a generator, this will return a Theano tensor!
"""
if hasattr(data, "to_numpy"):
if hasattr(data, "to_numpy") and hasattr(data, "isnull"):
# typically, but not limited to pandas objects
vals = data.to_numpy()
mask = np.isnan(vals)
mask = data.isnull().to_numpy()
if mask.any():
# there are missing values
ret = np.ma.MaskedArray(vals, mask)
Expand Down

0 comments on commit 6d5c78a

Please sign in to comment.