I\'ve read an SQL query into Pandas and the values are coming in as dtype \'object\', although they are strings, dates and integers. I am able to convert the date \'object\'
It's simple
pd.factorize(df.purchase)[0]
Example:
labels, uniques = pd.factorize(['b', 'b', 'a', 'c', 'b'])`
labels # array([0, 0, 1, 2, 0])
uniques # array(['b', 'a', 'c'], dtype=object)