Hi I'm new to python and pandas.
I have extracted the unique values of one of the column using pandas.
Now after getting the unique values of the column, which are string.
['Others, Senior Management-Finance, Senior Management-Sales'
'Consulting, Strategic planning, Senior Management-Finance'
'Client Servicing, Quality Control - Product/ Process, Strategic
planning'
'Administration/ Facilities, Business Analytics, Client Servicing'
'Sales & Marketing, Sales/ Business Development/ Account Management,
Sales Support']
I want to replace the string values with the unique integer value.
for simplicity I can give you the dummy input and output.
Input:
Col1
A
A
B
B
B
C
C
Unique df value will come as below
[ 'A' 'B' 'C' ]
after replacing the column should look like this
Col1
1
1
2
2
2
3
3
Please suggest me the way how can I do it by using loop or any other way because I have more than 300
unique values.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…