Skip to content

Commit

Permalink
Improving the robustness of the 'remove_columns' method
Browse files Browse the repository at this point in the history
  • Loading branch information
MooooCat committed Jun 21, 2024
1 parent 6d37fe1 commit 6c5dfde
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sdgx/data_processors/base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

from typing import Any, Dict

import pandas as pd

from sdgx.log import logger
from sdgx.data_models.metadata import Metadata
from sdgx.exceptions import SynthesizerProcessorError

Expand Down Expand Up @@ -72,7 +72,10 @@ def remove_columns(tabular_data: pd.DataFrame, column_name_to_remove: list) -> p
result_data = tabular_data.copy()

# Remove specified columns
result_data = result_data.drop(columns=column_name_to_remove)
try:
result_data = result_data.drop(columns=column_name_to_remove)
except KeyError:
logger.warning('Duplicate column removal occurred, which might lead to unintended consequences.')

return result_data

Expand Down

0 comments on commit 6c5dfde

Please sign in to comment.