Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
feat: Allow tuples, strings and lists for fillna
Browse files Browse the repository at this point in the history
The docstring refers to the word list, but the API will allow str, list
and tuple.
  • Loading branch information
oliverw1 authored and zero323 committed Sep 2, 2020
1 parent d0c15b9 commit 466f8a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions test-data/unit/sql-dataframe.test
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,15 @@ df.drop(col("id"), col("foo")) # E: No overload variant of "drop" of "DataFrame
# N: <1 more non-matching overload not shown>

[out]

[case fillNullValues]
from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()
df = spark.createDataFrame([(1,2)], schema=("id1", "id2"))

df.fillna(value=1, subset="id1")
df.fillna(value=1, subset=("id1", "id2"))
df.fillna(value=1, subset=["id1"])

[out]
4 changes: 3 additions & 1 deletion third_party/3/pyspark/sql/dataframe.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ class DataFrame(PandasMapOpsMixin, PandasConversionMixin):
) -> DataFrame: ...
@overload
def fillna(
self, value: LiteralType, subset: Optional[List[str]] = ...
self,
value: LiteralType,
subset: Optional[Union[str, Tuple[str, ...], List[str]]] = ...,
) -> DataFrame: ...
@overload
def fillna(self, value: Dict[str, LiteralType]) -> DataFrame: ...
Expand Down

0 comments on commit 466f8a1

Please sign in to comment.