问题
As you seen on the image we have three columns so i need to write code that can create new columns called aa and replace when whever see A replace it with 1 or B replace it 2 ETC.
Thank you
回答1:
IIUC use:
df['aa'] = df['categories'].map(df.drop_duplicates('categories').set_index('categories')['WOF'])
来源:https://stackoverflow.com/questions/62656932/replacing-the-value-in-new-data-frame-python