From dea6d9899cb50b59563bf87534ef22f26fb78089 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 10 Feb 2025 14:55:10 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BA=D0=BE=D0=B4=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BD=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D0=B8=20=D0=B1=D1=83=D0=B4?= =?UTF-8?q?=D1=83=D1=89=D0=B8=D1=85=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B9?= =?UTF-8?q?=20pandas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/converter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controller/converter.py b/src/controller/converter.py index 343576c..5367ede 100644 --- a/src/controller/converter.py +++ b/src/controller/converter.py @@ -13,10 +13,11 @@ class DataConverter(BaseDataConverter): def _replace_bool(dataframe: pd.DataFrame) -> pd.DataFrame: try: bool_columns = dataframe.columns[dataframe.isin([True, False]).all()] - dataframe.loc[:, bool_columns] = dataframe.loc[:, bool_columns].replace({True: 1, False: 0}) + dataframe = dataframe.astype({col: int for col in bool_columns}) + return dataframe except AttributeError as e: - logger.error(f"_replace_bool - AttributeError: Проверьте, что переданный объект является DataFrame. {e}") + logger.warning(f"_replace_bool - AttributeError: Проверьте, что переданный объект является DataFrame. {e}") return None except (TypeError, ValueError) as e: logger.error(f"_replace_bool - Ошибка типа или значения: {e}") @@ -46,7 +47,7 @@ class DataConverter(BaseDataConverter): dataframe = dataframe.loc[:, ~dataframe.columns.duplicated()] return dataframe except AttributeError as e: - logger.error(f"_fix_headers - AttributeError: Проверьте, что переданный объект является DataFrame. {e}") + logger.warning(f"_fix_headers - AttributeError: Проверьте, что переданный объект является DataFrame. {e}") return None except Exception as e: logger.error(f"_fix_headers - Непредвиденная ошибка: {e}")