|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from typing import TYPE_CHECKING, Any, Protocol |
| 4 | + |
| 5 | +if TYPE_CHECKING: |
| 6 | + from collections.abc import Mapping, Sequence |
| 7 | + |
| 8 | + from typing_extensions import Self |
| 9 | + |
| 10 | + from narwhals._compliant.any_namespace import ( |
| 11 | + CatNamespace, |
| 12 | + DateTimeNamespace, |
| 13 | + ListNamespace, |
| 14 | + StringNamespace, |
| 15 | + StructNamespace, |
| 16 | + ) |
| 17 | + from narwhals._compliant.namespace import CompliantNamespace |
| 18 | + from narwhals._utils import Version |
| 19 | + from narwhals.typing import ( |
| 20 | + ClosedInterval, |
| 21 | + FillNullStrategy, |
| 22 | + IntoDType, |
| 23 | + NonNestedLiteral, |
| 24 | + NumericLiteral, |
| 25 | + RankMethod, |
| 26 | + TemporalLiteral, |
| 27 | + ) |
| 28 | + |
| 29 | +__all__ = ["CompliantColumn"] |
| 30 | + |
| 31 | + |
| 32 | +class CompliantColumn(Protocol): |
| 33 | + """Common parts of `Expr`, `Series`.""" |
| 34 | + |
| 35 | + _version: Version |
| 36 | + |
| 37 | + def __add__(self, other: Any) -> Self: ... |
| 38 | + def __and__(self, other: Any) -> Self: ... |
| 39 | + def __eq__(self, other: object) -> Self: ... # type: ignore[override] |
| 40 | + def __floordiv__(self, other: Any) -> Self: ... |
| 41 | + def __ge__(self, other: Any) -> Self: ... |
| 42 | + def __gt__(self, other: Any) -> Self: ... |
| 43 | + def __invert__(self) -> Self: ... |
| 44 | + def __le__(self, other: Any) -> Self: ... |
| 45 | + def __lt__(self, other: Any) -> Self: ... |
| 46 | + def __mod__(self, other: Any) -> Self: ... |
| 47 | + def __mul__(self, other: Any) -> Self: ... |
| 48 | + def __ne__(self, other: object) -> Self: ... # type: ignore[override] |
| 49 | + def __or__(self, other: Any) -> Self: ... |
| 50 | + def __pow__(self, other: Any) -> Self: ... |
| 51 | + def __radd__(self, other: Any) -> Self: ... |
| 52 | + def __rand__(self, other: Any) -> Self: ... |
| 53 | + def __rfloordiv__(self, other: Any) -> Self: ... |
| 54 | + def __rmod__(self, other: Any) -> Self: ... |
| 55 | + def __rmul__(self, other: Any) -> Self: ... |
| 56 | + def __ror__(self, other: Any) -> Self: ... |
| 57 | + def __rpow__(self, other: Any) -> Self: ... |
| 58 | + def __rsub__(self, other: Any) -> Self: ... |
| 59 | + def __rtruediv__(self, other: Any) -> Self: ... |
| 60 | + def __sub__(self, other: Any) -> Self: ... |
| 61 | + def __truediv__(self, other: Any) -> Self: ... |
| 62 | + |
| 63 | + def __narwhals_namespace__(self) -> CompliantNamespace[Any, Any]: ... |
| 64 | + |
| 65 | + def abs(self) -> Self: ... |
| 66 | + def alias(self, name: str) -> Self: ... |
| 67 | + def cast(self, dtype: IntoDType) -> Self: ... |
| 68 | + def clip( |
| 69 | + self, |
| 70 | + lower_bound: Self | NumericLiteral | TemporalLiteral | None, |
| 71 | + upper_bound: Self | NumericLiteral | TemporalLiteral | None, |
| 72 | + ) -> Self: ... |
| 73 | + def cum_count(self, *, reverse: bool) -> Self: ... |
| 74 | + def cum_max(self, *, reverse: bool) -> Self: ... |
| 75 | + def cum_min(self, *, reverse: bool) -> Self: ... |
| 76 | + def cum_prod(self, *, reverse: bool) -> Self: ... |
| 77 | + def cum_sum(self, *, reverse: bool) -> Self: ... |
| 78 | + def diff(self) -> Self: ... |
| 79 | + def drop_nulls(self) -> Self: ... |
| 80 | + def ewm_mean( |
| 81 | + self, |
| 82 | + *, |
| 83 | + com: float | None, |
| 84 | + span: float | None, |
| 85 | + half_life: float | None, |
| 86 | + alpha: float | None, |
| 87 | + adjust: bool, |
| 88 | + min_samples: int, |
| 89 | + ignore_nulls: bool, |
| 90 | + ) -> Self: ... |
| 91 | + def exp(self) -> Self: ... |
| 92 | + def sqrt(self) -> Self: ... |
| 93 | + def fill_null( |
| 94 | + self, |
| 95 | + value: Self | NonNestedLiteral, |
| 96 | + strategy: FillNullStrategy | None, |
| 97 | + limit: int | None, |
| 98 | + ) -> Self: ... |
| 99 | + def is_between( |
| 100 | + self, lower_bound: Any, upper_bound: Any, closed: ClosedInterval |
| 101 | + ) -> Self: ... |
| 102 | + def is_finite(self) -> Self: ... |
| 103 | + def is_first_distinct(self) -> Self: ... |
| 104 | + def is_in(self, other: Any) -> Self: ... |
| 105 | + def is_last_distinct(self) -> Self: ... |
| 106 | + def is_nan(self) -> Self: ... |
| 107 | + def is_null(self) -> Self: ... |
| 108 | + def is_unique(self) -> Self: ... |
| 109 | + def log(self, base: float) -> Self: ... |
| 110 | + def mode(self) -> Self: ... |
| 111 | + def rank(self, method: RankMethod, *, descending: bool) -> Self: ... |
| 112 | + def replace_strict( |
| 113 | + self, |
| 114 | + old: Sequence[Any] | Mapping[Any, Any], |
| 115 | + new: Sequence[Any], |
| 116 | + *, |
| 117 | + return_dtype: IntoDType | None, |
| 118 | + ) -> Self: ... |
| 119 | + def rolling_mean( |
| 120 | + self, window_size: int, *, min_samples: int, center: bool |
| 121 | + ) -> Self: ... |
| 122 | + def rolling_std( |
| 123 | + self, window_size: int, *, min_samples: int, center: bool, ddof: int |
| 124 | + ) -> Self: ... |
| 125 | + def rolling_sum( |
| 126 | + self, window_size: int, *, min_samples: int, center: bool |
| 127 | + ) -> Self: ... |
| 128 | + def rolling_var( |
| 129 | + self, window_size: int, *, min_samples: int, center: bool, ddof: int |
| 130 | + ) -> Self: ... |
| 131 | + def round(self, decimals: int) -> Self: ... |
| 132 | + def shift(self, n: int) -> Self: ... |
| 133 | + def unique(self) -> Self: ... |
| 134 | + |
| 135 | + @property |
| 136 | + def str(self) -> StringNamespace[Self]: ... |
| 137 | + @property |
| 138 | + def dt(self) -> DateTimeNamespace[Self]: ... |
| 139 | + @property |
| 140 | + def cat(self) -> CatNamespace[Self]: ... |
| 141 | + @property |
| 142 | + def list(self) -> ListNamespace[Self]: ... |
| 143 | + @property |
| 144 | + def struct(self) -> StructNamespace[Self]: ... |
0 commit comments