Skip to content
Closed
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions python/pyspark/pandas/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ def to_json(
lines: bool = True,
partition_cols: Optional[Union[str, List[str]]] = None,
index_col: Optional[Union[str, List[str]]] = None,
ignoreNullFields: bool = False,
**options: Any,
) -> Optional[str]:
"""
Expand Down Expand Up @@ -946,6 +947,7 @@ def to_json(
the options in PySpark's API documentation for `spark.write.json(...)`.
It has a higher priority and overwrites all other options.
This parameter only works when `path` is specified.
ignoreNullFields: if set to True and path is provided, writer omits columns with all NaN or Null values.

Returns
--------
Expand Down Expand Up @@ -978,6 +980,9 @@ def to_json(
0 a
1 c
"""
default_options: Dict[str, Any] = {"ignoreNullFields": False}
options = {**default_options, **options}

if "options" in options and isinstance(options.get("options"), dict) and len(options) == 1:
options = options.get("options")

Expand Down