From 98ea6993dfa90fb1337fc76dd295af14d5ef3c12 Mon Sep 17 00:00:00 2001 From: julian fong Date: Wed, 14 Aug 2024 17:05:24 -0400 Subject: [PATCH] fixed naming convention for indices to use __index__{col_name} --- skpro/datatypes/_adapter/polars.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/skpro/datatypes/_adapter/polars.py b/skpro/datatypes/_adapter/polars.py index 42bc8ba3..1f337a5d 100644 --- a/skpro/datatypes/_adapter/polars.py +++ b/skpro/datatypes/_adapter/polars.py @@ -69,8 +69,9 @@ def convert_polars_to_pandas_with_index(obj): obj = obj.collect() pd_df = obj.to_pandas() - if "__index__" in obj.columns: - pd_df = pd_df.set_index("__index__", drop=True) + for col in obj.columns: + if col.startswith("__index__"): + pd_df = pd_df.set_index(col, drop=True) return pd_df @@ -104,8 +105,9 @@ def convert_pandas_to_polars_with_index( """ from polars import from_pandas + obj_index_name = obj.index.name obj.reset_index() - obj.rename(columns={"index": "__index__"}) + obj.rename(columns={obj_index_name: f"__index__{obj_index_name}"}) pl_df = from_pandas( data=obj,