@@ -121,6 +121,43 @@ def _take_nd_ndarray(
121
121
return out
122
122
123
123
124
+ def take_1d (
125
+ arr : ArrayLike ,
126
+ indexer : np .ndarray ,
127
+ fill_value = None ,
128
+ allow_fill : bool = True ,
129
+ ) -> ArrayLike :
130
+ """
131
+ Specialized version for 1D arrays. Differences compared to take_nd:
132
+
133
+ - Assumes input (arr, indexer) has already been converted to numpy array / EA
134
+ - Only works for 1D arrays
135
+
136
+ To ensure the lowest possible overhead.
137
+
138
+ TODO(ArrayManager): mainly useful for ArrayManager, otherwise can potentially
139
+ be removed again if we don't end up with ArrayManager.
140
+ """
141
+ if not isinstance (arr , np .ndarray ):
142
+ # ExtensionArray -> dispatch to their method
143
+ return arr .take (indexer , fill_value = fill_value , allow_fill = allow_fill )
144
+
145
+ indexer , dtype , fill_value , mask_info = _take_preprocess_indexer_and_fill_value (
146
+ arr , indexer , 0 , None , fill_value , allow_fill
147
+ )
148
+
149
+ # at this point, it's guaranteed that dtype can hold both the arr values
150
+ # and the fill_value
151
+ out = np .empty (indexer .shape , dtype = dtype )
152
+
153
+ func = _get_take_nd_function (
154
+ arr .ndim , arr .dtype , out .dtype , axis = 0 , mask_info = mask_info
155
+ )
156
+ func (arr , indexer , out , fill_value )
157
+
158
+ return out
159
+
160
+
124
161
def take_2d_multi (
125
162
arr : np .ndarray , indexer : np .ndarray , fill_value = np .nan
126
163
) -> np .ndarray :
0 commit comments