I have an array (in numpy, or in pandas) containing (non-unique) strings. Some of them are ints written as strings, some comprise of both digits and letters. What I would like to do is to map these strings onto (some) int or float values, in order to process them further.
I don't mean simple int(string,base). I mean a procedure that would, say go through all the strings, and then say "Aha, so lets's assign to this string such and such 'int/float-key'".
What's the most efficient way of doing that?
['1', 'a5', 'cde9', '1', 'cde9']
. Do you want the result to be[1, 5, 9, 1, 9]
or[0, 1, 2, 0, 2]
? – Joe Kington Jun 26 at 17:05