You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ru...@apache.org on 2026/05/06 02:17:34 UTC
(spark) branch master updated: [SPARK-56731][PYTHON] Fix type annotation for DataFrame.replace
This is an automated email from the ASF dual-hosted git repository.
zhengruifeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 4ec0da950ccb [SPARK-56731][PYTHON] Fix type annotation for DataFrame.replace
4ec0da950ccb is described below
commit 4ec0da950ccb4b129b7c50d24ee7d93232375aee
Author: Tian Gao <ga...@hotmail.com>
AuthorDate: Wed May 6 10:17:21 2026 +0800
[SPARK-56731][PYTHON] Fix type annotation for DataFrame.replace
### What changes were proposed in this pull request?
Fix type annotation for `DataFrame.replace`
### Why are the changes needed?
The old one is actually wrong because you can't pass `subset` as a positional argument if you skip `value`.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
CI.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #55694 from gaogaotiantian/df-replace-type-hint.
Authored-by: Tian Gao <ga...@hotmail.com>
Signed-off-by: Ruifeng Zheng <ru...@foxmail.com>
---
python/pyspark/sql/classic/dataframe.py | 3 ++-
python/pyspark/sql/dataframe.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/python/pyspark/sql/classic/dataframe.py b/python/pyspark/sql/classic/dataframe.py
index 3501f01135d8..0d4ea4732512 100644
--- a/python/pyspark/sql/classic/dataframe.py
+++ b/python/pyspark/sql/classic/dataframe.py
@@ -1413,6 +1413,7 @@ class DataFrame(ParentDataFrame, PandasMapOpsMixin, PandasConversionMixin):
def replace(
self,
to_replace: Dict["LiteralType", "OptionalPrimitiveType"],
+ *,
subset: Optional[List[str]] = ...,
) -> ParentDataFrame: ...
@@ -1424,7 +1425,7 @@ class DataFrame(ParentDataFrame, PandasMapOpsMixin, PandasConversionMixin):
subset: Optional[List[str]] = ...,
) -> ParentDataFrame: ...
- def replace( # type: ignore[misc]
+ def replace(
self,
to_replace: Union[
"LiteralType", List["LiteralType"], Dict["LiteralType", "OptionalPrimitiveType"]
diff --git a/python/pyspark/sql/dataframe.py b/python/pyspark/sql/dataframe.py
index b2586a2d7a18..d77e5a63dba9 100644
--- a/python/pyspark/sql/dataframe.py
+++ b/python/pyspark/sql/dataframe.py
@@ -5221,6 +5221,7 @@ class DataFrame:
def replace(
self,
to_replace: Dict["LiteralType", "OptionalPrimitiveType"],
+ *,
subset: Optional[List[str]] = ...,
) -> "DataFrame": ...
@@ -5232,7 +5233,7 @@ class DataFrame:
subset: Optional[List[str]] = ...,
) -> "DataFrame": ...
- @dispatch_df_method # type: ignore[misc]
+ @dispatch_df_method
def replace(
self,
to_replace: Union[
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org