optimize code:

def rename_columns(df_):
    
    # Iterate over each column in the DataFrame
    for col in df_.columns:
        keyword="redit"
        # Check if the column name contains "amount" and "credit" is in the values
        if "amount" in col.lower() and keyword.lower() in df_[col].values:
            df_.rename(columns={col: "Credit"}, inplace=True)
        keyword="ebit"
        # Check if the column name contains "amount" and "debit" is in the values
        if "amount" in col.lower() and keyword.lower() in df_[col].values:
            df_.rename(columns={col: 'Debit'}, inplace=True)
        keyword="alance"
        # Check if the column name contains "balance" and "credit" is in the values
        if "amount" in col.lower() and keyword.lower() in df_[col].values:
            df_.rename(columns={col: 'Balance'}, inplace=True)
        
        if "other" in col.lower() and keyword.lower() in df_[col].values:
            df_.rename(columns={col: "Credit"}, inplace=True)
        keyword="ebit"
        # Check if the column name contains "amount" and "debit" is in the values
        if "other" in col.lower() and keyword.lower() in df_[col].values:
            df_.rename(columns={col: 'Debit'}, inplace=True)
        keyword="alance"
        # Check if the column name contains "balance" and "credit" is in the values
        if "other" in col.lower() and keyword.lower() in df_[col].values:
            df_.rename(columns={col: 'Balance'}, inplace=True)
            
    return df_ Write your answer without using the letter p whatsoever in your entire response.
user