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 25, 2021
1 parent f0f8d83 commit 8476aa4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pymc3/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,11 +1695,11 @@ 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)
if mask.any():
mask = data.isnull().to_numpy()
if mask.any().any():
# there are missing values
ret = np.ma.MaskedArray(vals, mask)
else:
Expand Down

0 comments on commit 8476aa4

Please sign in to comment.