You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently our disallowing unicode formula strings on Py2 was being
rather annoying for people using `from __future__ import
unicode_literals`. Start allowing them in limited circumstances.
Fixesgh-53.
Doing this works fine:
foo = pd.DataFrame(dict(a=[1,2.0], b=[4,5.0]))
patsy.dmatrices('a ~ b', foo)
However, if the formula is given by a unicode string:
patsy.dmatrices(u'a ~ b', foo)
An exception is raised:
ValueError: design matrix must be real-valued floating point
The exception is very misleading about the nature of the problem. I thought an inf or nan had crept into the dataframe, but no bad values were there.
One possible fix is to send the first argument of dmatrices through the str() function:
patsy.dmatrices(str(u'a ~ b'), foo)
Another possible fix is to raise print a different error message so that the user has some clear idea of the cause of the problem.
I'm using patsy version 0.3.0
Thanks!
The text was updated successfully, but these errors were encountered: