In a column risklevels I want to replace Small with 1, Medium with 5 and High with 15. I tried:
dfm.replace({\'risk\':{\'Small\': \'1\'}},{\'risk\':{\'Medium
String replace each string (Small, Medium, High) for the new string (1,5,15)\
If dfm is the dataframe name, column is the column name.
dfm.column = dfm.column.str.replace('Small', '1') dfm.column = dfm.column.str.replace('Medium', '5') dfm.column = dfm.column.str.replace('High', '15')