|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import TYPE_CHECKING, Any, Literal, Protocol, overload |
| 5 | +from typing import TYPE_CHECKING, Any, Protocol |
6 | 6 |
|
7 | 7 | from narwhals._plan.compliant.column import EagerBroadcast, SupportsBroadcast |
8 | 8 | from narwhals._plan.compliant.typing import ( |
9 | | - ColumnT_co, |
10 | 9 | FrameT_contra, |
11 | 10 | LengthT, |
12 | 11 | NamespaceT_co, |
|
15 | 14 | SeriesT_co, |
16 | 15 | StoresVersion, |
17 | 16 | ) |
18 | | -from narwhals._plan.typing import ( |
19 | | - IntoExpr, |
20 | | - NativeDataFrameT, |
21 | | - NativeFrameT, |
22 | | - NativeSeriesT, |
23 | | - Seq, |
24 | | -) |
25 | 17 | from narwhals._utils import Version |
26 | 18 |
|
27 | 19 | if TYPE_CHECKING: |
28 | | - from collections.abc import Iterable, Iterator, Mapping, Sequence |
29 | | - |
30 | 20 | from typing_extensions import Self |
31 | 21 |
|
32 | 22 | from narwhals._plan import expressions as ir |
33 | | - from narwhals._plan.compliant.group_by import ( |
34 | | - CompliantGroupBy, |
35 | | - DataFrameGroupBy, |
36 | | - EagerDataFrameGroupBy, |
37 | | - GroupByResolver, |
38 | | - Grouped, |
39 | | - ) |
40 | | - from narwhals._plan.compliant.namespace import EagerNamespace |
41 | | - from narwhals._plan.dataframe import BaseFrame, DataFrame |
42 | 23 | from narwhals._plan.expressions import ( |
43 | 24 | BinaryExpr, |
44 | 25 | FunctionExpr, |
|
48 | 29 | functions as F, |
49 | 30 | ) |
50 | 31 | from narwhals._plan.expressions.boolean import IsBetween, IsFinite, IsNan, IsNull, Not |
51 | | - from narwhals._plan.options import SortMultipleOptions |
52 | | - from narwhals._plan.typing import OneOrIterable |
53 | | - from narwhals.dtypes import DType |
54 | | - from narwhals.typing import IntoDType, IntoSchema, PythonLiteral |
| 32 | + from narwhals.typing import IntoDType, PythonLiteral |
55 | 33 |
|
56 | 34 |
|
57 | 35 | class ExprDispatch(StoresVersion, Protocol[FrameT_contra, R_co, NamespaceT_co]): |
@@ -307,103 +285,3 @@ class LazyScalar( |
307 | 285 | LazyExpr[FrameT_contra, SeriesT, LengthT], |
308 | 286 | Protocol[FrameT_contra, SeriesT, LengthT], |
309 | 287 | ): ... |
310 | | - |
311 | | - |
312 | | -class CompliantBaseFrame(StoresVersion, Protocol[ColumnT_co, NativeFrameT]): |
313 | | - _native: NativeFrameT |
314 | | - |
315 | | - def __narwhals_namespace__(self) -> Any: ... |
316 | | - @property |
317 | | - def _group_by(self) -> type[CompliantGroupBy[Self]]: ... |
318 | | - @property |
319 | | - def native(self) -> NativeFrameT: |
320 | | - return self._native |
321 | | - |
322 | | - @property |
323 | | - def columns(self) -> list[str]: ... |
324 | | - def to_narwhals(self) -> BaseFrame[NativeFrameT]: ... |
325 | | - @classmethod |
326 | | - def from_native(cls, native: NativeFrameT, /, version: Version) -> Self: |
327 | | - obj = cls.__new__(cls) |
328 | | - obj._native = native |
329 | | - obj._version = version |
330 | | - return obj |
331 | | - |
332 | | - def _with_native(self, native: NativeFrameT) -> Self: |
333 | | - return self.from_native(native, self.version) |
334 | | - |
335 | | - @property |
336 | | - def schema(self) -> Mapping[str, DType]: ... |
337 | | - def _evaluate_irs( |
338 | | - self, nodes: Iterable[NamedIR[ir.ExprIR]], / |
339 | | - ) -> Iterator[ColumnT_co]: ... |
340 | | - def select(self, irs: Seq[NamedIR]) -> Self: ... |
341 | | - def select_names(self, *column_names: str) -> Self: ... |
342 | | - def with_columns(self, irs: Seq[NamedIR]) -> Self: ... |
343 | | - def sort(self, by: Seq[NamedIR], options: SortMultipleOptions) -> Self: ... |
344 | | - def drop(self, columns: Sequence[str], *, strict: bool = True) -> Self: ... |
345 | | - def drop_nulls(self, subset: Sequence[str] | None) -> Self: ... |
346 | | - |
347 | | - |
348 | | -class CompliantDataFrame( |
349 | | - CompliantBaseFrame[SeriesT, NativeDataFrameT], |
350 | | - Protocol[SeriesT, NativeDataFrameT, NativeSeriesT], |
351 | | -): |
352 | | - @property |
353 | | - def _group_by(self) -> type[DataFrameGroupBy[Self]]: ... |
354 | | - @property |
355 | | - def _grouper(self) -> type[Grouped]: |
356 | | - from narwhals._plan.compliant.group_by import Grouped |
357 | | - |
358 | | - return Grouped |
359 | | - |
360 | | - @classmethod |
361 | | - def from_dict( |
362 | | - cls, data: Mapping[str, Any], /, *, schema: IntoSchema | None = None |
363 | | - ) -> Self: ... |
364 | | - def group_by_agg( |
365 | | - self, by: OneOrIterable[IntoExpr], aggs: OneOrIterable[IntoExpr], / |
366 | | - ) -> Self: |
367 | | - """Compliant-level `group_by(by).agg(agg)`, allows `Expr`.""" |
368 | | - return self._grouper.by(by).agg(aggs).resolve(self).evaluate(self) |
369 | | - |
370 | | - def group_by_names(self, names: Seq[str], /) -> DataFrameGroupBy[Self]: |
371 | | - """Compliant-level `group_by`, allowing only `str` keys.""" |
372 | | - return self._group_by.by_names(self, names) |
373 | | - |
374 | | - def group_by_resolver(self, resolver: GroupByResolver, /) -> DataFrameGroupBy[Self]: |
375 | | - """Narwhals-level resolved `group_by`. |
376 | | -
|
377 | | - `keys`, `aggs` are already parsed and projections planned. |
378 | | - """ |
379 | | - return self._group_by.from_resolver(self, resolver) |
380 | | - |
381 | | - def to_narwhals(self) -> DataFrame[NativeDataFrameT, NativeSeriesT]: ... |
382 | | - @overload |
383 | | - def to_dict(self, *, as_series: Literal[True]) -> dict[str, SeriesT]: ... |
384 | | - @overload |
385 | | - def to_dict(self, *, as_series: Literal[False]) -> dict[str, list[Any]]: ... |
386 | | - @overload |
387 | | - def to_dict( |
388 | | - self, *, as_series: bool |
389 | | - ) -> dict[str, SeriesT] | dict[str, list[Any]]: ... |
390 | | - def to_dict( |
391 | | - self, *, as_series: bool |
392 | | - ) -> dict[str, SeriesT] | dict[str, list[Any]]: ... |
393 | | - def __len__(self) -> int: ... |
394 | | - def with_row_index(self, name: str) -> Self: ... |
395 | | - def row(self, index: int) -> tuple[Any, ...]: ... |
396 | | - |
397 | | - |
398 | | -class EagerDataFrame( |
399 | | - CompliantDataFrame[SeriesT, NativeDataFrameT, NativeSeriesT], |
400 | | - Protocol[SeriesT, NativeDataFrameT, NativeSeriesT], |
401 | | -): |
402 | | - @property |
403 | | - def _group_by(self) -> type[EagerDataFrameGroupBy[Self]]: ... |
404 | | - def __narwhals_namespace__(self) -> EagerNamespace[Self, SeriesT, Any, Any]: ... |
405 | | - def select(self, irs: Seq[NamedIR]) -> Self: |
406 | | - return self.__narwhals_namespace__()._concat_horizontal(self._evaluate_irs(irs)) |
407 | | - |
408 | | - def with_columns(self, irs: Seq[NamedIR]) -> Self: |
409 | | - return self.__narwhals_namespace__()._concat_horizontal(self._evaluate_irs(irs)) |
0 commit comments