Skip to content

Commit

Permalink
Remove duplicate rows which differ only by description when printing …
Browse files Browse the repository at this point in the history
…to GAMS
  • Loading branch information
olejandro committed Feb 14, 2024
1 parent 2e0fa61 commit e179e62
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xl2times/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ def write_dd_files(

def convert_set(df: DataFrame):
has_description = "TEXT" in df.columns
# Remove duplicate rows, ignoring text column
if has_description:
query_columns = [c for c in df.columns if c != "TEXT"]
df = df.drop_duplicates(subset=query_columns, keep="last")
for row in df.itertuples(index=False):
row_str = "'.'".join(
(str(x) for k, x in row._asdict().items() if k != "TEXT")
Expand Down

0 comments on commit e179e62

Please sign in to comment.