Skip to content

Commit

Permalink
fixed naming convention for indices to use __index__{col_name}
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-fong committed Aug 14, 2024
1 parent ae9ee7b commit 98ea699
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions skpro/datatypes/_adapter/polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 98ea699

Please sign in to comment.