From 6af4a6f67128f83585f29710bfb7c5a62411a6ed Mon Sep 17 00:00:00 2001 From: Mike Gerber Date: Tue, 3 Dec 2024 17:02:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Remove=20unused/obsolete=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mods4pandas/lib.py | 30 ------------------------------ src/mods4pandas/mods4pandas.py | 2 +- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/src/mods4pandas/lib.py b/src/mods4pandas/lib.py index 11c88a3..8a65901 100644 --- a/src/mods4pandas/lib.py +++ b/src/mods4pandas/lib.py @@ -301,36 +301,6 @@ def flatten(d: MutableMapping, parent='', separator='_'): return dict(items) -def dicts_to_df(data_list: List[Dict], *, index_column) -> pd.DataFrame: - """ - Convert the given list of dicts to a Pandas DataFrame. - - The keys of the dicts make the columns. - """ - - # Build columns from keys - columns = [] - for m in data_list: - for c in m.keys(): - if c not in columns: - columns.append(c) - - # Build data table - data = [[m.get(c) for c in columns] for m in data_list] - - # Build index - if isinstance(index_column, str): - index = [m[index_column] for m in data_list] - elif isinstance(index_column, tuple): - index = [[m[c] for m in data_list] for c in index_column] - index = pd.MultiIndex.from_arrays(index, names=index_column) - else: - raise ValueError(f"index_column must") - - df = pd.DataFrame(data=data, index=index, columns=columns) - return df - - def valid_column_key(k): if re.match("^[a-zA-Z0-9 _@/:\[\]-]+$", k): return True diff --git a/src/mods4pandas/mods4pandas.py b/src/mods4pandas/mods4pandas.py index 4479844..ee1f45d 100755 --- a/src/mods4pandas/mods4pandas.py +++ b/src/mods4pandas/mods4pandas.py @@ -18,7 +18,7 @@ import click import pandas as pd from tqdm import tqdm -from .lib import sorted_groupby, TagGroup, ns, flatten, dicts_to_df, insert_into_db, insert_into_db_multiple +from .lib import sorted_groupby, TagGroup, ns, flatten, insert_into_db, insert_into_db_multiple