Pandas:如果为 NaN,则重命名多索引数据框中的索引标签

Pandas: rename a index label in multiindex dataframe if NaN

如何替换下面df的内部索引标签?

Question                                 profile_gender. Gender           
Values                                    Male     Female
Question                    Values                                  
XCS_3. Think of a problem?  NaN        25.192318  25.900784

至:

Question                                 profile_gender. Gender           
Values                                    Male     Female
Question                    Values                                  
XCS_3. Think of a problem?  Okay Done   25.192318  25.900784

我失败的尝试:

df.index = df.index.set_levels(['Okay Done'], 1)

什么都不做,甚至不抛出错误代码

看来我必须替换整个索引,这很烦人。

df.index = pd.MultiIndex.from_tuples([('XCS_3. Think of a problem?', ' Okay Done')],
                                     names=['Question', 'Values'])