From c068d797841ed7ff4975a76d98e4f641cab0aff9 Mon Sep 17 00:00:00 2001 From: FBruzzesi Date: Mon, 11 Nov 2024 22:07:53 +0100 Subject: [PATCH] very old pandas --- narwhals/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/narwhals/utils.py b/narwhals/utils.py index 386b5b6e5..7c8701248 100644 --- a/narwhals/utils.py +++ b/narwhals/utils.py @@ -348,8 +348,17 @@ def maybe_set_index( if column_names: msg = "Cannot set index using column names on a Series" raise ValueError(msg) + + if ( + df_any._compliant_series._implementation is Implementation.PANDAS + and df_any._compliant_series._backend_version < (1,) + ): # pragma: no cover + native_obj = native_obj.set_axis(keys, inplace=False) + else: + native_obj = native_obj.set_axis(keys) + return df_any._from_compliant_series( # type: ignore[no-any-return] - df_any._compliant_series._from_native_series(native_obj.set_axis(keys)) + df_any._compliant_series._from_native_series(native_obj) ) else: return df_any # type: ignore[no-any-return]