|
13 | 13 | from narwhals._expression_parsing import ExprKind |
14 | 14 | from narwhals._expression_parsing import evaluate_output_names_and_aliases |
15 | 15 | from narwhals._expression_parsing import is_scalar_like |
16 | | -from narwhals.dependencies import get_numpy |
17 | | -from narwhals.dependencies import is_numpy_array |
18 | 16 | from narwhals.exceptions import ColumnNotFoundError |
19 | 17 | from narwhals.utils import Implementation |
20 | 18 | from narwhals.utils import generate_temporary_column_name |
|
25 | 23 |
|
26 | 24 | from narwhals._arrow.dataframe import ArrowDataFrame |
27 | 25 | from narwhals._arrow.namespace import ArrowNamespace |
28 | | - from narwhals.dtypes import DType |
29 | 26 | from narwhals.utils import Version |
30 | 27 | from narwhals.utils import _FullContext |
31 | 28 |
|
@@ -203,44 +200,6 @@ def func(df: ArrowDataFrame) -> Sequence[ArrowSeries]: |
203 | 200 | version=self._version, |
204 | 201 | ) |
205 | 202 |
|
206 | | - def map_batches( |
207 | | - self: Self, |
208 | | - function: Callable[[Any], Any], |
209 | | - return_dtype: DType | type[DType] | None, |
210 | | - ) -> Self: |
211 | | - def func(df: ArrowDataFrame) -> list[ArrowSeries]: |
212 | | - input_series_list = self._call(df) |
213 | | - output_names = [input_series.name for input_series in input_series_list] |
214 | | - result = [function(series) for series in input_series_list] |
215 | | - |
216 | | - if is_numpy_array(result[0]): |
217 | | - result = [ |
218 | | - df.__narwhals_namespace__() |
219 | | - ._create_compliant_series(array) |
220 | | - .alias(output_name) |
221 | | - for array, output_name in zip(result, output_names) |
222 | | - ] |
223 | | - elif (np := get_numpy()) is not None and np.isscalar(result[0]): |
224 | | - result = [ |
225 | | - df.__narwhals_namespace__() |
226 | | - ._create_compliant_series([array]) |
227 | | - .alias(output_name) |
228 | | - for array, output_name in zip(result, output_names) |
229 | | - ] |
230 | | - if return_dtype is not None: |
231 | | - result = [series.cast(return_dtype) for series in result] |
232 | | - return result |
233 | | - |
234 | | - return self.__class__( |
235 | | - func, |
236 | | - depth=self._depth + 1, |
237 | | - function_name=self._function_name + "->map_batches", |
238 | | - evaluate_output_names=self._evaluate_output_names, |
239 | | - alias_output_names=self._alias_output_names, |
240 | | - backend_version=self._backend_version, |
241 | | - version=self._version, |
242 | | - ) |
243 | | - |
244 | 203 | def cum_count(self: Self, *, reverse: bool) -> Self: |
245 | 204 | return self._reuse_series("cum_count", reverse=reverse) |
246 | 205 |
|
|
0 commit comments