merge fails on string and object dtype

Bug #516609 reported by kwgoodman
8
This bug affects 1 person
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:\ChristopherPalm\dev\code\be\interface\<ipython console> in <module>()

r:\christopherPalm\dev\code\la\la\deflarry.py in merge(self, other, update)
   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:\christopherpalm\dev\code\la\la\deflarry.py(2353)merge()
   2352 mask = np.isfinite(lar2.x)
-> 2353 lar1.x[mask] = lar2.x[mask]
   2354

ipdb> mask
NotImplemented

Revision history for this message
kwgoodman (kwgoodman) wrote :

Thanks for the bug report. I committed a fix in r157. Give it a try.

Changed in larry:
assignee: nobody → kwgoodman (kwgoodman)
importance: Undecided → High
status: New → Fix Committed
milestone: none → 0.1
Revision history for this message
Chris (chrispalm) wrote :

Thanks! It worked fine for my purpose and I will be able to remove many lines of code where I merge in various ways outside larry.

kwgoodman (kwgoodman)
Changed in larry:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.