import pandas as pd
from loguru import logger


def check_recommendations(recommendations_dict, df_profile):
    try:
        for i in range(df_profile.shape[0]):
            column = df_profile.iloc[i, df_profile.columns.get_loc('column')]
            column_lower = f'{column}_lower'
            column_upper = f'{column}_upper'
            recommendations_dict[column_lower] = recommendations_dict[column_lower] - \
                                                 (df_profile.iloc[i, df_profile.columns.get_loc('std_dev')])*1000/24
            recommendations_dict[column_upper] = recommendations_dict[column_upper] + \
                                                 df_profile.iloc[i, df_profile.columns.get_loc('std_dev')]
            if recommendations_dict[column_lower] < df_profile.iloc[i, df_profile.columns.
                    get_loc('golden_batch_minimum')]:
                recommendations_dict[column_lower] = df_profile.iloc[i, df_profile.columns.
                get_loc('golden_batch_minimum')]
            if recommendations_dict[column_upper] > df_profile.iloc[i, df_profile.columns.
                    get_loc('golden_batch_maximum')]:
                recommendations_dict[column_upper] = df_profile.iloc[i, df_profile.columns.
                get_loc('golden_batch_maximum')]
        return recommendations_dict
    except Exception as e:
        logger.exception(f'Exception - {e}')