Skip to content
Closed
Changes from 9 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
7 changes: 7 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 All @@ -904,6 +905,9 @@ def to_json(

.. note:: output JSON format is different from pandas'. It always use `orient='records'`
for its output. This behaviour might have to change in the near future.

.. note:: Set ignoreNullFields keyword argument to `True` and path is provided,
writer omits columns with all NaN or Null values.

Note NaN's and None will be converted to null and datetime objects
will be converted to UNIX timestamps.
Expand Down Expand Up @@ -978,6 +982,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