From a1dfa2b9b7e4bbecf6ab0d28a01a73c4d79a69f2 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 27 Sep 2023 15:02:22 +0200 Subject: [PATCH] :alien: update code to pandas 2.0 - update depreciated functionality in pandas -> some scripts might have further depreciation warnings --- vaep/models/collab.py | 2 +- vaep/tests/test_sampling.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vaep/models/collab.py b/vaep/models/collab.py index bb37a9b46..ff9f461a1 100644 --- a/vaep/models/collab.py +++ b/vaep/models/collab.py @@ -56,7 +56,7 @@ def combine_data(train_df: pd.DataFrame, val_df: pd.DataFrame) -> Tuple[pd.DataF Pandas DataFrame of concatenated samples of training and validation data. Fraction of samples originally in validation data. """ - X = train_df.append(val_df).reset_index() + X = pd.concat([train_df, val_df]).reset_index() frac = len(val_df) / (len(train_df) + len(val_df)) return X, frac diff --git a/vaep/tests/test_sampling.py b/vaep/tests/test_sampling.py index bed514892..813c79331 100644 --- a/vaep/tests/test_sampling.py +++ b/vaep/tests/test_sampling.py @@ -53,5 +53,7 @@ def test_sample_data(random_data): series_sampled) + len(series_not_sampled) assert X.index.difference( series_sampled.index.append(series_not_sampled.index)).empty - assert series_sampled.loc[pd.IndexSlice[:, excluded_feat]].empty - assert not series_not_sampled.loc[pd.IndexSlice[:, excluded_feat]].empty + idx_excluded = series_sampled.index.isin(excluded_feat, level=1) + assert series_sampled.loc[idx_excluded].empty + idx_excluded = series_not_sampled.index.isin(excluded_feat, level=1) + assert not series_not_sampled.loc[idx_excluded].empty