@@ -72,6 +72,17 @@ def test_to_ndarray_numpy_ndarray_numpy_numeric(dtype):
72
72
npt .assert_array_equal (result , array )
73
73
74
74
75
+ @pytest .mark .parametrize ("dtype" , [None , np .str_ ])
76
+ def test_to_ndarray_numpy_ndarray_numpy_string (dtype ):
77
+ """
78
+ Test the _to_ndarray function with 1-D NumPy arrays of strings.
79
+ """
80
+ array = np .array (["a" , "b" , "c" ], dtype = dtype )
81
+ result = _to_ndarray (array )
82
+ _check_result (result )
83
+ npt .assert_array_equal (result , array )
84
+
85
+
75
86
@pytest .mark .parametrize (
76
87
"dtype" ,
77
88
[
@@ -146,6 +157,26 @@ def test_to_ndarray_pandas_series_numeric_with_na(dtype):
146
157
npt .assert_array_equal (result , np .array ([1 , np .nan , 3 ], dtype = np .float64 ))
147
158
148
159
160
+ @pytest .mark .parametrize (
161
+ "dtype" ,
162
+ [
163
+ # None,
164
+ # np.str_,
165
+ "string[python]" ,
166
+ "string[pyarrow]" ,
167
+ "string[pyarrow_numpy]" ,
168
+ ],
169
+ )
170
+ def test_to_ndarray_pandas_series_string (dtype ):
171
+ """
172
+ Test the _to_ndarray function with pandas Series with string dtype.
173
+ """
174
+ series = pd .Series (["a" , "bcd" , "12345" ], dtype = dtype )
175
+ result = _to_ndarray (series )
176
+ _check_result (result )
177
+ npt .assert_array_equal (result , series )
178
+
179
+
149
180
@pytest .mark .skipif (not _HAS_PYARROW , reason = "pyarrow is not installed" )
150
181
@pytest .mark .parametrize (
151
182
"dtype" ,
@@ -184,3 +215,14 @@ def test_to_ndarray_pyarrow_array_float16():
184
215
result = _to_ndarray (array )
185
216
_check_result (result )
186
217
npt .assert_array_equal (result , array )
218
+
219
+
220
+ @pytest .mark .skipif (not _HAS_PYARROW , reason = "pyarrow is not installed" )
221
+ def test_to_ndarray_pyarrow_array_string ():
222
+ """
223
+ Test the _to_ndarray function with pyarrow string array.
224
+ """
225
+ array = pa .array (["a" , "bcd" , "12345" ], type = pa .string ())
226
+ result = _to_ndarray (array )
227
+ _check_result (result )
228
+ npt .assert_array_equal (result , array )
0 commit comments