azure - convert string into numeric data in the dataframe using python -


if have field in dataframe

a12 a13 a13 a12 a14 

we need convert string into

a12   1 a13   2 a13   2 a12   1 a14   3 

try this:

arr=dataframe['old_col'].unique() dataframe['new_col']=dataframe['old_col'].apply(lambda x: arr.index(x)) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -