With a dataframe like this:
>>> df = pd.DataFrame([
['a', 'b', 'c'],
['d', 'e', 'f'],
['x', 'y', 'z'],
])
We can get the ord()
mapping for each character:
>>> ordinals = df.apply(lambda x: [ord(c) for c in x])
>>> ordinals
0 1 2
0 97 98 99
1 100 101 102
2 120 121 122
Is it possible to get the same result in a vectorised manner, so that we avoid using apply
on each row which is extremely slow with 1.5M+ rows?