Skip to content

Commit c3284ba

Browse files
fangchenliclaude
andcommitted
TST: fix test_convert_dtypes for PANDAS_FUTURE_INFER_STRING=0
When using_infer_string is False, string columns start as object dtype and get converted to Arrow, so memory is not shared. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 36097d7 commit c3284ba

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/tests/copy_view/test_astype.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,12 @@ def test_convert_dtypes(using_infer_string):
216216
df_orig = df.copy()
217217
df2 = df.convert_dtypes()
218218

219-
assert tm.shares_memory(get_array(df2, "a"), get_array(df, "a"))
219+
if using_infer_string:
220+
# String column is already Arrow-backed, so memory is shared
221+
assert tm.shares_memory(get_array(df2, "a"), get_array(df, "a"))
222+
else:
223+
# String column converts from object to Arrow, no memory sharing
224+
assert not tm.shares_memory(get_array(df2, "a"), get_array(df, "a"))
220225
assert tm.shares_memory(get_array(df2, "d"), get_array(df, "d"))
221226
assert tm.shares_memory(get_array(df2, "b"), get_array(df, "b"))
222227
assert tm.shares_memory(get_array(df2, "c"), get_array(df, "c"))

0 commit comments

Comments
 (0)