merge fails on string and object dtype
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
larry |
Fix Released
|
High
|
kwgoodman |
Bug Description
larry.merge is a very nice function but I can only use it when I only have numbers in my larry.
Would it be possible to modify larry.merge to allow str or even object data types? The problem is that numpy.isfinite, used in merge, is not implemented for str. A possible solution would be to check for dtype and instead of np.isfinite, in the str case, check for empty string e.g. mask = lar2.x != ''. Would that work?
Here's a simple example where it fails for a larry of str.
In [33]: a = larry(['',''])
In [34]: a.merge(a, update=True)
-------
IndexError Traceback (most recent call last)
R:\ChristopherP
r:\christopherP
2351 else:
2352 mask = np.isfinite(lar2.x)
-> 2353 lar1.x[mask] = lar2.x[mask]
2354
2355 return lar1
IndexError: index must be either an int or a sequence
> r:\christopherp
2352 mask = np.isfinite(lar2.x)
-> 2353 lar1.x[mask] = lar2.x[mask]
2354
ipdb> mask
NotImplemented
Changed in larry: | |
status: | Fix Committed → Fix Released |
Thanks for the bug report. I committed a fix in r157. Give it a try.