d = {'col': ['ana', 'ben', 'carl', 'dennis', 'earl', ...]}
df = pd.DataFrame(data = d)
I have an example dataframe here. Usually, if there are more than 5 unique values, OHE will not be used (correct me if I'm wrong).
Instead, mapping using a dictionary is used.
An example dictionary would be
dict = {'ana': 1, 'ben': 2, 'carl':, 3, ...}
Is there a library or any way to make this automatic (though manual mapping may be better as you know which values are mapped to which number)?
EDIT 1
Using ascii_lowercase, I am able to map single letter strings to integers. But as shown above, what if my strings are not single letters?