merge str or object data

Asked by Chris

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

Question information

Language:
English Edit question
Status:
Solved
For:
larry Edit question
Assignee:
kwgoodman Edit question
Last query:
Last reply:
Revision history for this message
kwgoodman (kwgoodman) said :
#1

Fix comitted