We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 50be246 commit 8614993Copy full SHA for 8614993
pandas/tests/indexes/common.py
@@ -912,6 +912,19 @@ def test_contains_requires_hashable_raises(self):
912
with pytest.raises(TypeError):
913
{} in idx._engine
914
915
+ def test_copy_copies_cache(self):
916
+ # GH32898
917
+ idx = self.create_index()
918
+ idx.get_loc(idx[0]) # populates the _cache.
919
+ copy = idx.copy()
920
+
921
+ # check that the copied cache is a copy of the original
922
+ assert idx._cache == copy._cache
923
+ assert idx._cache is not copy._cache
924
+ # cache values should reference the same object
925
+ for key, val in idx._cache.items():
926
+ assert copy._cache[key] is val, key
927
928
def test_shallow_copy_copies_cache(self):
929
# GH32669
930
idx = self.create_index()
0 commit comments