I want to generate numbers based on strings in a column within a dataframe. I want to create numbers to represent each unique string.
Below is an example and the desired outcome.
String Desired outcome
A 1
A 1
B 2
C 3
D 4
The code below doesn't work because it creates many columns.
dummies = pd.get_dummies(df['String'])