Skip to content

Commit 82be657

Browse files
authored
Merge branch 'main' into series-from-numpy
2 parents 1f67693 + d860054 commit 82be657

File tree

17 files changed

+25
-22
lines changed

17 files changed

+25
-22
lines changed

narwhals/_arrow/series_dt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def unit(self) -> TimeUnit: # NOTE: Unsafe (native).
3030
def time_zone(self) -> str | None: # NOTE: Unsafe (narwhals).
3131
return cast("Datetime", self.compliant.dtype).time_zone
3232

33-
def to_string(self: Self, format: str) -> ArrowSeries: # noqa: A002
33+
def to_string(self: Self, format: str) -> ArrowSeries:
3434
# PyArrow differs from other libraries in that %S also prints out
3535
# the fractional part of the second...:'(
3636
# https://arrow.apache.org/docs/python/generated/pyarrow.compute.strftime.html

narwhals/_arrow/series_str.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def split(self: Self, by: str) -> ArrowSeries:
6161
split_series = pc.split_pattern(self.native, by) # type: ignore[call-overload]
6262
return self.from_native(split_series)
6363

64-
def to_datetime(self: Self, format: str | None) -> ArrowSeries: # noqa: A002
64+
def to_datetime(self: Self, format: str | None) -> ArrowSeries:
6565
format = parse_datetime_format(self.native) if format is None else format
6666
strptime: Incomplete = pc.strptime
6767
timestamp_array: pa.Array[pa.TimestampScalar[Any, Any]] = strptime(

narwhals/_compliant/any_namespace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_categories(self) -> CompliantT_co: ...
2828

2929

3030
class DateTimeNamespace(_StoresCompliant[CompliantT_co], Protocol[CompliantT_co]):
31-
def to_string(self, format: str) -> CompliantT_co: ... # noqa: A002
31+
def to_string(self, format: str) -> CompliantT_co: ...
3232
def replace_time_zone(self, time_zone: str | None) -> CompliantT_co: ...
3333
def convert_time_zone(self, time_zone: str) -> CompliantT_co: ...
3434
def timestamp(self, time_unit: TimeUnit) -> CompliantT_co: ...
@@ -78,7 +78,7 @@ def ends_with(self, suffix: str) -> CompliantT_co: ...
7878
def contains(self, pattern: str, *, literal: bool) -> CompliantT_co: ...
7979
def slice(self, offset: int, length: int | None) -> CompliantT_co: ...
8080
def split(self, by: str) -> CompliantT_co: ...
81-
def to_datetime(self, format: str | None) -> CompliantT_co: ... # noqa: A002
81+
def to_datetime(self, format: str | None) -> CompliantT_co: ...
8282
def to_lowercase(self) -> CompliantT_co: ...
8383
def to_uppercase(self) -> CompliantT_co: ...
8484

narwhals/_compliant/expr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def get_categories(self) -> EagerExprT:
861861
class EagerExprDateTimeNamespace(
862862
EagerExprNamespace[EagerExprT], DateTimeNamespace[EagerExprT], Generic[EagerExprT]
863863
):
864-
def to_string(self, format: str) -> EagerExprT: # noqa: A002
864+
def to_string(self, format: str) -> EagerExprT:
865865
return self.compliant._reuse_series_namespace("dt", "to_string", format=format)
866866

867867
def replace_time_zone(self, time_zone: str | None) -> EagerExprT:
@@ -1024,7 +1024,7 @@ def slice(self, offset: int, length: int | None) -> EagerExprT:
10241024
def split(self, by: str) -> EagerExprT:
10251025
return self.compliant._reuse_series_namespace("str", "split", by=by)
10261026

1027-
def to_datetime(self, format: str | None) -> EagerExprT: # noqa: A002
1027+
def to_datetime(self, format: str | None) -> EagerExprT:
10281028
return self.compliant._reuse_series_namespace("str", "to_datetime", format=format)
10291029

10301030
def to_lowercase(self) -> EagerExprT:

narwhals/_dask/expr_dt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ def weekday(self: Self) -> DaskExpr:
7272
"weekday",
7373
)
7474

75-
def to_string(self: Self, format: str) -> DaskExpr: # noqa: A002
75+
def to_string(self: Self, format: str) -> DaskExpr:
7676
return self._compliant_expr._from_call(
77-
lambda _input, format: _input.dt.strftime(format.replace("%.f", ".%f")), # noqa: A006
77+
lambda _input, format: _input.dt.strftime(format.replace("%.f", ".%f")),
7878
"strftime",
7979
format=format,
8080
)

narwhals/_dask/expr_str.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def split(self: Self, by: str) -> DaskExpr:
8888
by=by,
8989
)
9090

91-
def to_datetime(self: Self, format: str | None) -> DaskExpr: # noqa: A002
91+
def to_datetime(self: Self, format: str | None) -> DaskExpr:
9292
return self._compliant_expr._from_call(
93-
lambda _input, format: dd.to_datetime(_input, format=format), # noqa: A006
93+
lambda _input, format: dd.to_datetime(_input, format=format),
9494
"to_datetime",
9595
format=format,
9696
)

narwhals/_duckdb/expr_dt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def nanosecond(self: Self) -> DuckDBExpr:
6767
"nanosecond",
6868
)
6969

70-
def to_string(self: Self, format: str) -> DuckDBExpr: # noqa: A002
70+
def to_string(self: Self, format: str) -> DuckDBExpr:
7171
return self._compliant_expr._from_call(
7272
lambda _input: FunctionExpression("strftime", _input, lit(format)),
7373
"to_string",

narwhals/_duckdb/expr_str.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def replace(self: Self, pattern: str, value: str, *, literal: bool, n: int) -> N
106106
msg = "`replace` is currently not supported for DuckDB"
107107
raise NotImplementedError(msg)
108108

109-
def to_datetime(self: Self, format: str | None) -> DuckDBExpr: # noqa: A002
109+
def to_datetime(self: Self, format: str | None) -> DuckDBExpr:
110110
if format is None:
111111
msg = "Cannot infer format with DuckDB backend, please specify `format` explicitly."
112112
raise NotImplementedError(msg)

narwhals/_pandas_like/series_dt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def total_nanoseconds(self: Self) -> PandasLikeSeries:
178178
s_abs = s_abs.astype(int_dtype_mapper(s.dtype))
179179
return self._compliant_series._from_native_series(s_abs * s_sign)
180180

181-
def to_string(self: Self, format: str) -> PandasLikeSeries: # noqa: A002
181+
def to_string(self: Self, format: str) -> PandasLikeSeries:
182182
# Polars' parser treats `'%.f'` as pandas does `'.%f'`
183183
# PyArrow interprets `'%S'` as "seconds, plus fractional seconds"
184184
# and doesn't support `%f`

narwhals/_pandas_like/series_str.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def split(self: Self, by: str) -> PandasLikeSeries:
8484
self._compliant_series._native_series.str.split(pat=by),
8585
)
8686

87-
def to_datetime(self: Self, format: str | None) -> PandasLikeSeries: # noqa: A002
87+
def to_datetime(self: Self, format: str | None) -> PandasLikeSeries:
8888
if format is not None and any(x in format for x in ("%z", "Z")):
8989
# We know that the inputs are timezone-aware, so we can directly pass
9090
# `utc=True` for better performance.

0 commit comments

Comments
 (0)