File tree Expand file tree Collapse file tree 4 files changed +16
-12
lines changed Expand file tree Collapse file tree 4 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -280,11 +280,13 @@ def _type(self: Self) -> pa.DataType:
280280 def len (self : Self , * , _return_py_scalar : bool = True ) -> int :
281281 return maybe_extract_py_scalar (len (self ._native_series ), _return_py_scalar )
282282
283- def filter (self : Self , other : ArrowSeries | list [bool | None ]) -> Self :
284- if not (isinstance (other , list ) and all (isinstance (x , bool ) for x in other )):
285- _ , other_native = extract_native (self , other )
283+ def filter (self : Self , predicate : ArrowSeries | list [bool | None ]) -> Self :
284+ if not (
285+ isinstance (predicate , list ) and all (isinstance (x , bool ) for x in predicate )
286+ ):
287+ _ , other_native = extract_native (self , predicate )
286288 else :
287- other_native = other
289+ other_native = predicate
288290 return self ._from_native_series (self ._native_series .filter (other_native )) # pyright: ignore[reportArgumentType]
289291
290292 def mean (self : Self , * , _return_py_scalar : bool = True ) -> float :
Original file line number Diff line number Diff line change @@ -607,8 +607,8 @@ def arg_true(self) -> Self:
607607
608608 def filter (self , * predicates : Self ) -> Self :
609609 plx = self .__narwhals_namespace__ ()
610- other = plx .all_horizontal (* predicates )
611- return self ._reuse_series_implementation ("filter" , other = other )
610+ predicate = plx .all_horizontal (* predicates )
611+ return self ._reuse_series_implementation ("filter" , predicate = predicate )
612612
613613 def drop_nulls (self ) -> Self :
614614 return self ._reuse_series_implementation ("drop_nulls" )
Original file line number Diff line number Diff line change @@ -328,11 +328,13 @@ def arg_max(self: Self) -> int:
328328
329329 # Binary comparisons
330330
331- def filter (self : Self , other : Any ) -> PandasLikeSeries :
332- if not (isinstance (other , list ) and all (isinstance (x , bool ) for x in other )):
333- _ , other_native = align_and_extract_native (self , other )
331+ def filter (self : Self , predicate : Any ) -> PandasLikeSeries :
332+ if not (
333+ isinstance (predicate , list ) and all (isinstance (x , bool ) for x in predicate )
334+ ):
335+ _ , other_native = align_and_extract_native (self , predicate )
334336 else :
335- other_native = other
337+ other_native = predicate
336338 return self ._from_native_series (self ._native_series .loc [other_native ]).alias (
337339 self .name
338340 )
Original file line number Diff line number Diff line change @@ -1578,7 +1578,7 @@ def __ror__(self: Self, other: Any) -> Self:
15781578 def __invert__ (self : Self ) -> Self :
15791579 return self ._from_compliant_series (self ._compliant_series .__invert__ ())
15801580
1581- def filter (self : Self , other : Any ) -> Self :
1581+ def filter (self : Self , predicate : Any ) -> Self :
15821582 """Filter elements in the Series based on a condition.
15831583
15841584 Returns:
@@ -1597,7 +1597,7 @@ def filter(self: Self, other: Any) -> Self:
15971597 dtype: int64
15981598 """
15991599 return self ._from_compliant_series (
1600- self ._compliant_series .filter (self ._extract_native (other ))
1600+ self ._compliant_series .filter (self ._extract_native (predicate ))
16011601 )
16021602
16031603 # --- descriptive ---
You can’t perform that action at this time.
0 commit comments