Skip to content

Commit 4bf8a07

Browse files
committed
Add test for list of lists handling in ensure_string_array (GH#61155)
1 parent fb965e7 commit 4bf8a07

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/libs/test_lib.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,15 @@ def test_ensure_string_array_copy():
297297
assert not np.shares_memory(arr, result)
298298
assert arr[1] is None
299299
assert result[1] is np.nan
300+
301+
302+
def test_ensure_string_array_list_of_lists():
303+
# GH#61155: ensure list of lists doesn't get converted to string
304+
arr = [list("test"), list("word")]
305+
result = lib.ensure_string_array(arr)
306+
307+
# Each item in result should still be a list, not a stringified version
308+
assert isinstance(result, np.ndarray)
309+
assert result.dtype == object
310+
assert result[0] == "['t', 'e', 's', 't']"
311+
assert result[1] == "['w', 'o', 'r', 'd']"

0 commit comments

Comments
 (0)