'Replacing some values in a column based on another data frame column

I have a feedback dataframe with two feedback categories 'MULTICHOICE' and 'TEXT'. I want to translate questions and responses of 'MULTICHOICE' category and insert in the original dataframe. This is the code I tried.

 def translate_feedback_to_english(user_feedback_df):
    feedback_df = user_feedback_df.loc[user_feedback_df.question_type == 'MULTICHOICE']
    responses = translate_responses(feedback_df)
    feedback_df = pd.merge(feedback_df, responses, on="response", how="left")
    user_feedback_df.loc[user_feedback_df.question_type == 'MULTICHOICE','response_en']= feedback_df.loc[:,'response_en']
    return user_feedback_df, feedback_df

However The response_en I'm getting contains nulls for MULTICHOICE questions even though my response isn't null. It's not an issue with translating, The same words are translated on top. This is my user_feedback_df

        question_type         response response_en
0     MULTICHOICE         Too Much    TOO MUCH
1     MULTICHOICE        Very High   VERY HIGH
2     MULTICHOICE            متدني    INFERIOR
3     MULTICHOICE             ضعيف        WEAK
4     MULTICHOICE             كثير       A LOT
..            ...              ...         ...
229   MULTICHOICE             كافي         NaN
230          TEXT  Achanda Overall         NaN
231   MULTICHOICE            متدني         NaN
232   MULTICHOICE              جيد         NaN
233   MULTICHOICE         غير كافي         NaN

However, Everything is correctly translated in my feedback_df.

    question_type   response response_en
0     MULTICHOICE   Too Much    TOO MUCH
1     MULTICHOICE  Very High   VERY HIGH
2     MULTICHOICE      متدني    INFERIOR
3     MULTICHOICE       ضعيف        WEAK
4     MULTICHOICE       كثير       A LOT
..            ...        ...         ...
196   MULTICHOICE      مقبول  ACCEPTABLE
197   MULTICHOICE       كافي      ENOUGH
198   MULTICHOICE      متدني    INFERIOR
199   MULTICHOICE        جيد        GOOD
200   MULTICHOICE   غير كافي  NOT ENOUGH
enter code here


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source