- Notifications
You must be signed in to change notification settings - Fork15
Open
Description
This is probably a crazy idea (and I don't currently have a use case), but could we make it easy to apply a dict to map values? For example, to make the following easier and more reliable (i.e., not rely on inlining the dict):
In [10]:v=gb.Vector.from_values(np.arange(5),np.arange(5))In [11]:vOut[11]:"v_2"nvalssizedtypeformatgb.Vector55INT64full-------------------------------------index01234value01234In [12]:v.apply(lambdax: {0:0,1:2,2:4,3:6,4:8}[x]).new()Out[12]:"v_4"nvalssizedtypeformatgb.Vector55INT64full-------------------------------------index01234value02468
This requires Numba to know the types of the dictionary. Also, I don't know how easy it would be to have a default value. This may require its own method.
This is inspired by the Pandas functionality to be able to usex.map(d) to apply a dict or Series mapping.