I am opening a new question related to this one :
Python pandas df rename index using regex
This solution works perfectly, but I need to adapt if the df is empty.
I have 8 df to rename the Index and sometimes those df will be empty. And if the df is empty I have this error : AttributeError: Can only use .str accessor with string values (i.e. inferred_type is ‘string’, ‘unicode’ or ‘mixed’). Whcih is normal because I cannot replace a str if it is no existant .
df_rc.index = df_rc.index.str.replace(r'(d+)', '')