diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 904cd0c69c2..8d67afa34bc 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -8,7 +8,6 @@ import textwrap import warnings from collections import Counter, abc -from functools import cached_property from typing import ( Any, Callable, @@ -2266,7 +2265,7 @@ def truncate(self, before=None, after=None, axis=0, copy=True): slicer[axis] = slice(before, after) return self.loc[tuple(slicer)].copy() - @cached_property + @property def loc(self): """Select rows and columns by label or boolean mask. @@ -2332,7 +2331,7 @@ def loc(self): """ return self._loc_indexer_type(self) - @cached_property + @property def iloc(self): """Select values by position. diff --git a/python/cudf/cudf/tests/test_indexing.py b/python/cudf/cudf/tests/test_indexing.py index f49b9b02076..b1d871b6abc 100644 --- a/python/cudf/cudf/tests/test_indexing.py +++ b/python/cudf/cudf/tests/test_indexing.py @@ -1,5 +1,6 @@ # Copyright (c) 2021-2024, NVIDIA CORPORATION. +import weakref from datetime import datetime from itertools import combinations @@ -2257,6 +2258,16 @@ def test_scalar_loc_row_categoricalindex(): assert_eq(result, expected) +@pytest.mark.parametrize("klass", [cudf.DataFrame, cudf.Series]) +@pytest.mark.parametrize("indexer", ["iloc", "loc"]) +def test_iloc_loc_no_circular_reference(klass, indexer): + obj = klass([0]) + ref = weakref.ref(obj) + getattr(obj, indexer)[0] + del obj + assert ref() is None + + def test_loc_setitem_empty_dataframe(): pdf = pd.DataFrame(index=["index_1", "index_2", "index_3"]) gdf = cudf.from_pandas(pdf)