nxcals.api.extraction.data.builders.DataFrame.toJSON

DataFrame.toJSON(use_unicode: bool = True) RDD[str]

Converts a DataFrame into a RDD of string.

Each row is turned into a JSON document as one element in the returned RDD.

New in version 1.3.0.

Parameters:

use_unicode (bool, optional, default True) – Whether to convert to unicode or not.

Return type:

RDD

Examples

>>> df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
>>> df.toJSON().first()
'{"age":2,"name":"Alice"}'