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]: v
Out[11]:
"v_2" nvals size dtype format
gb.Vector 5 5 INT64 full
-------------------------------------
index 0 1 2 3 4
value 0 1 2 3 4
In [12]: v.apply(lambda x: {0: 0, 1: 2, 2: 4, 3: 6, 4: 8}[x]).new()
Out[12]:
"v_4" nvals size dtype format
gb.Vector 5 5 INT64 full
-------------------------------------
index 0 1 2 3 4
value 0 2 4 6 8
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 use x.map(d)
to apply a dict or Series mapping.