There are different categories for a column in the dataframe and want to merge/rename these different columns into 3 categories and this column is object data type.I have tried using below code.. i..e using map function and also tried converting the object data type into categorical but i dont see the expected result and also see a value like when i query the unique values for that column.
Code: Tried different codes to acheive the below 3 categories
Happiest, Unhappy, Neutral
df['Status'].dtype = object
df['Status'] = df['Status'].rename({'Happy':'Happiest','Smile':'Happiest','Sad':'Un happy','ok':'Neutral'},
inplace=True)
Or
Converted to categorical
df2['Status'] = df2['Status'].astype('category')
df['Status'] = df['Status'].cat.rename_categories({'Happy':'Happiest','Smile':'Happiest','Sad':'Un happy','ok':'Neutral'})
Or
df['Status'] = df['Status'].map({'Happy':'Happiest','Smile':'Happiest','Sad':'Un happy','ok':'Neutral'},
inplace=True)
The output of all the above tried codes are nan, happiest, Neutral or completely nan.